Add photo from metafield at the bottom of the product information section.

Add photo from metafield at the bottom of the product information section.

nativesons
Tourist
18 0 2

I added a metafield to include a photo on the product page with the hopes of displaying that photo under the product description by connecting a dynamic block. It allows us to connect dynamic text fields from the metafields, however not images. Is there a way to connect an image from the metafields in under the product description in the product information section?

 

Replies 5 (5)

Liquid_xPert_SJ
Shopify Partner
1373 142 212

@nativesons 

can you please share the page url OR screenshot for better understanding that what you want to accomplish.

 

Thanks

- If you need any technical assistance, feel free to send me a DM. You no longer have to search for answers without getting a response.
- Please don't forget to Like and Mark Solution to the post that helped you. Thanks!
- Your Shopify Solution Specialist For further discussion contact: Email ID- Liqud_3xPert_SJ OR Whatsapp
- Buy a Coffee for me to get more frequently help 🙂
- Hire Me to unlock the full potential of your e-commerce store Now 🙂- If you need any technical assistance, feel free to send me a DM. You no longer have to search for answers without getting a response.
- Please don't forget to Like and Mark Solution to the post that helped you. Thanks!
- Your Shopify Solution Specialist For further discussion contact: Email ID- Liqud_3xPert_SJ OR Whatsapp
- Buy a Coffee for me to get more frequently help 🙂
- Hire Me to unlock the full potential of your e-commerce store Now 🙂
- Need THEME UPDATES but have custom codes? No worries, for an affordable price.

Sweans
Shopify Partner
429 89 126

Hi @nativesons,

Here is a step-by-step guide to achieve your goal of displaying a metafield image under the product description in the product information section on

Shopify:

Step 1: Create a Metafield for the Image:
Navigate to Settings > Custom data > Products.

Sweans_0-1721285336439.png

 

Step 2: Click Add definition and fill out the following details:
Name: Description Image
Select type: File
Validation: Accept only images (png, jpg, etc.)
Save the metafield definition.

Sweans_1-1721285380853.png

 

Step 3: Upload the desired image to the metafield for each product.

Sweans_2-1721285433598.png

 

Step 4: Navigate to Online Store > Themes > Actions > Edit code.

Step 5: Find the sections/main-product.liquid file where your product details are rendered and Add a Dynamic Block for the Image in block section

{
"type": "description_image",
"name": "Description Image",
"limit": 1
},

 

Sweans_3-1721285481772.png

 

Step 6: Add following code before endcase

{%- when 'description_image' -%}
{% if product.metafields.custom.description_image %}
<div class="description-image">
<img src="{{ product.metafields.custom.description_image | file_url }}" width="auto" height="auto">
</div>
{% endif %}


(screenshot 5)

Sweans_4-1721285519093.png

 

Step 7: Add custom block to product template after description

Sweans_5-1721285570948.png


If you need further assistance, feel free to reach out!
I hope this helps! If it does, please like it and mark it as a solution!

Regards,

Sweans

- Was my reply helpful? Please Like and Accept the Solution or let me know by Buying me coffee!
- Want to modify or custom changes on store Hire me.
- Feel free to contact me at info@sweans.com regarding any help.
- To know more about me check out www.sweans.com

nativesons
Tourist
18 0 2

I seem to be having a few troubles with this as there are a few differences in the way that my code is rendered.

 

First I wanted to double check that I am pasting the Dynamic Block code in the correct section.

Screenshot 2024-07-18 at 7.41.43 AM.png

 From there I was unable to find any {% endcase %}

I posted it here and it gave me an error stating that the tag "when" was unknown. It appears that our code uses an "if" tag for many things.

Screenshot 2024-07-18 at 7.46.50 AM.png

 If I switch the "when" tag to an "if" it will allow me to save but it doesn't seem to have any effect.

Screenshot 2024-07-18 at 7.53.25 AM.png

 Thank you for the assistance.

Sweans
Shopify Partner
429 89 126

Sure, I'd be happy to assist. Please insert the following code on line 57, immediately after the for loop:

if block.type == 'flavor_profile'
if product.metafields.custom.flavor_profile
echo '<img src="{{ product.metafields.custom.flavor_profile | img_url }}" width="auto" height="auto">'
endif
endif


If you need further assistance, feel free to reach out!
I hope this helps! If it does, please like it and mark it as a solution!

Regards,
Sweans

- Was my reply helpful? Please Like and Accept the Solution or let me know by Buying me coffee!
- Want to modify or custom changes on store Hire me.
- Feel free to contact me at info@sweans.com regarding any help.
- To know more about me check out www.sweans.com

Dan-From-Ryviu
Shopify Partner
11360 2226 2399

Hi @nativesons 

You could try to add your metafield definitions code into this and check 

<img src="your metafield definition code" alt="product.title">

 

- Found this helpful? Hit "Like" and "Accept as Solution"!
- Reton: Loyalty & Rewards - Earn points through tasks, redeem for discounts, and enjoy exclusive VIP rewards!
- Ryviu - Reviews & QA app: Collect product reviews, import reviews from AliExpress, Amazon, Etsy, Walmart, Shopee, Dhgate and CSV.
- Lookfy Gallery: Lookbook Image - Gain customers with photo gallery, video & shoppable image
Built for Shopify

Reelfy‑Shoppable Videos+Reels: Create shoppable videos to engage customers and drive more sales.
- En...
Sign up now.