New Shopify Certification now available: Liquid Storefronts for Theme Developers

Adding Image/Video (metafield) to Tab on product page

TBS2022
Trailblazer
243 2 36

Hello

I have on my product page a "How to use" accordion tab .

I would like to be able to add wither an image or a video per product through metafield.

Please can you help

I am using the Impulse theme

 

Replies 2 (2)
Small_Task_Help
Shopify Partner
314 9 22

Hi,

 

Create Metafield Definitions (Define your metafield. For images, you might use image_url and for videos, video_url or similar.)

Add Metafield Values to Products

Display Metafield Values in Your Store

at product.liquid or similar

For image

 

{% if product.metafields.custom.image_url %}
  <img src="{{ product.metafields.custom.image_url | img_url: 'medium' }}" alt="Product Image">
{% endif %}

 

 

For video 

 

{% if product.metafields.custom.video_url %}
  <div class="video-container">
    <iframe width="560" height="315" src="{{ product.metafields.custom.video_url }}" frameborder="0" allowfullscreen></iframe>
  </div>
{% endif %}

 

Still need help you can contact us . Details are in the signature

Click here to Contact and Get Shopify Store Help
E-mail - hi@shopifysmalltask.com
We are Shopify Store Small Tasks and Customization Experts
TBS2022
Trailblazer
243 2 36

thank you - where shall i add this code please?