How do i add an overlay image to products based on product tags?

Topic summary

Issue: A user needed to conditionally display an overlay image on product pages in Shopify’s Dawn theme, but only for products with specific tags. Their initial CSS code applied the overlay to all products.

Solution Provided: Wrap the CSS in Liquid template logic that checks product tags:

  • Use {% for tag in product.tags %} to loop through tags
  • Add {% if tag contains 'your-tag' %} to check for specific tag names
  • Place the CSS inside <style> tags within this conditional block
  • Close with {% endif %} and {% endfor %}

Outcome: The original poster confirmed the solution works after adding the <style> wrapper to the provided code. They successfully implemented it for products tagged ‘ROYALFORD’.

Follow-up Question: Another user asked whether this overlay can also appear on collection page thumbnails, not just individual product pages—this remains unanswered.

Summarized with AI on November 5. AI used: claude-sonnet-4-5-20250929.

Hello,

I need to add an image on my products, but only if the tags meet specific names, I already have the CSS code but i do need the way to make it conditional or with statement, below is the CSS code but when i use it the image appeared on all products, I’m using Dawn theme.

Thanks in Advance

.product__media-item modal-opener{
position: relative;
}
.product__media-item modal-opener:after{
content: ‘’;
position: absolute;
top: 5px;
left: 5px;
width: 15%;
height: 15%;
background-image: url(‘https://cdn.shopify.com/s/files/1/0634/5061/1897/files/free.png’);
background-size: contain;
background-repeat: no-repeat;
z-index: 2;
}

Hi @Mohamed_Evisu

This is Noah from PageFly - Shopify Page Builder App

Please add this condition with the tags like this

{% for tag in product.tags %}

  {% if tag contains 'your-tag' %}
    .product__media-item modal-opener{
position: relative;
}
.product__media-item modal-opener:after{
content: '';
position: absolute;
top: 5px;
left: 5px;
width: 15%;
height: 15%;
background-image: url('https://cdn.shopify.com/s/files/1/0634/5061/1897/files/free.png');
background-size: contain;
background-repeat: no-repeat; 
z-index: 2;
}
  {% endif %}

{% endfor %}

You should put this code in a product page. For that can check all the tags

Hope this can help you solve the issue

Best regards,

Noah | PageFly


Thank you Noah for your reply,

Unfortunately the code not working properly, please check the image.

I added style to your code and it is working now, thank you Noah

{% for tag in product.tags %}

{% if tag contains ‘ROYALFORD’ %}

.product__media-item modal-opener{ position: relative; } .product__media-item modal-opener:after{ content: ''; position: absolute; top: 5px; left: 5px; width: 20%; height: 20%; background-image: url('[https://cdn.shopify.com/s/files/1/0634/5061/1897/files/2ywarranty.png](https://cdn.shopify.com/s/files/1/0634/5061/1897/files/2ywarranty.png)'); background-size: contain; background-repeat: no-repeat; z-index: 1; }

{% endif %}

{% endfor %}

1 Like

Thanks for the solution! It worked for me.

1 Like

This has worked perfectly on the product pages themselves but is there any way to make the overlay appear on the thumbnails when browsing collections as well?