If empty metafields - do not display issue

If empty metafields - do not display issue

Markas_Suika
Visitor
2 0 1

I've seen numerous posts here with solutions that provide a code snippet that suppose to work but no one says where you should put it. In my case I've created multiple metfields with the option to upload a file (image), I use it in my product pages section to display certain images, but I have multiple sections and if I do not add images to each metafield then it is displayed without an image. I just want to know where should I put this code:

{% if product.metafields.custom.product_page_image_banner_10 != blank %}
       		{{ product.metafields.custom.product_page_image_banner_10 }},
           {%  endif %}
Reply 1 (1)

Guleria
Shopify Partner
4181 812 1168

Hello @Markas_Suika ,

 

If you are looking to add it inside the theme files then it all depends on the requirement and the theme you are using. 
And if you are trying to add it with dynamic source then I suggest use custom liquid block.
And I think your code should be

{% if product.metafields.custom.product_page_image_banner_10.value %}
       		// you code goes here
           {%  endif %}

 

Thanks

 


 

- Custom themes, UI/UX design, ongoing maintenance & support.
- Drop an email   if you are looking for quick fix or any customization
- Email: guleriathakur43@gmail.com Skype: live:navrocks1
- Try GEMPAGES a great page builder