Hello,
I’m encountering an issue with displaying images from metaobjects in a Custom Liquid block. Despite multiple attempts and configurations, the images either do not display or appear as broken. Here’s a summary of what I’ve tried so far:
-
Setup Details:
- I created a metaobject for energy efficiency classes with a field for uploading SVG images (icon).
- The metaobject is correctly linked to products via a metafield reference.
- The handle and file URLs are properly assigned, and the images exist on Shopify CDN (tested directly with their URLs).
-
Custom Liquid Code:
- I’ve written Liquid code to access the metaobject reference, retrieve the handle, and map it to the appropriate SVG file URL.
- The code works when hardcoding the image URLs directly, but it fails when fetching them dynamically from the metaobject field.
-
Diagnostics:
- Using debug code, I confirmed that the metaobject reference is connected to the product.
- However, metaobject.reference.fields.ikonica | file_url either returns nothing or an invalid URL.
- The metaobject handle and other properties (like title) are either missing or not accessible in the Liquid block.
-
Alternative Approaches Tried:
- Using metafields instead of metaobjects (works but results in duplicating images across multiple products).
- Displaying the images directly via a Shopify dynamic block (works, but lacks flexibility for more complex configurations).
-
Issue Summary:
- Images display perfectly when using metafields, but not when using metaobject references in Liquid.
- The issue seems tied to Shopify’s handling of metaobject references in Custom Liquid.
Can someone help identify what might be causing this issue or suggest a workaround?
Screeshot: https://prnt.sc/ho-fw-fGHT1b
Thank you in advance! ![]()