Dear Shopify Support,
I am encountering an issue while attempting to render images stored in a metafield of type “file” within a metaobject. The problem arises when trying to display pairing images associated with a product, and while the pairing name is rendering fine, the images are not showing up.
Here’s an overview of the situation:
Issue Overview:
- I have set up a metaobject for product pairings, and each pairing has a
pairing_image
field, which is a media object (file). - I am using Shopify Liquid to display these pairing images alongside the names, but the images are not rendering.
- The
pairing_image
field in the metaobject is correctly populated with an image file. I have confirmed that it is a media object, not just a regular file or URL.
What I’ve Tried:
- I have used the
media_url
filter to resolve the media object, similar to how I successfully render other images (e.g., producer logos). - I’ve ensured that the
pairing_image
is a media object, and I am using the correct syntax for rendering it:
liquid
Copy code
<img src="{{ pairing_image | media_url: 'medium' }}" alt="{{ pairing_name }}" width="150" height="150">
- The pairing name renders correctly, but the image remains blank or does not load.
What I Need Help With:
- I need confirmation on whether the
pairing_image
field is properly handled as a media object in the metaobject. - Is there something specific I need to check in my metafield setup to ensure it treats the image as a valid media object, and not just a regular file reference or URL?
- Any additional steps to help render images correctly from metafields inside a metaobject.
here is the code im using
Pairs Well With
{% for pairing in pairings %}
{% assign pairing_name = pairing.pairing %}
{% assign pairing_image = pairing.pairing_image %}
<div class="pairing">
<!-- Display Pairing Name -->
<p>{{ pairing_name }}</p>
<!-- Render Pairing Image -->
{% if pairing_image != blank %}
<!-- Use media_url to render the image as media -->
<img src="{{ pairing_image | media_url: 'medium' }}" alt="{{ pairing_name }}" width="150" height="150">
{% else %}
<p>No image available for this pairing.</p>
{% endif %}
</div>
{% endfor %}
{% else %}
No pairings metaobject found for this product.
{% endif %}