After you have added a custom field of type media, with the administration or via plugin, you can assign media objects to the different entities. This is often used for products to add more images to the product detail page. If you want to learn more about custom fields you might want to take a look at this guide: Adding custom fields.
In the product detail page template, the key page.product.translated.customFields.xxx with the xxx, which is replaced with the corresponding custom field, contains the UUID of the media. Now the ID has just to be resolved with the function searchMedia:
This function resolves out the corresponding media objects for the given IDs in order to continue working with them afterwards. Here is an example with a custom field (custom_sports_media_id) on the product detail page: