Solved

Can I replace text with an image in Shopify Liquid code?

Andre_Borges
Excursionist
32 0 12

Hello, been searching everywhere for an answer but i got nothing.

 

{{ product.description | replace: 'THISWORD', 'this' }}

Im trying to replace THISWORD with this, but i want this to be an image.

How can i do this in code?

Accepted Solution (1)
Not applicable

This is an accepted solution.

Hi @Andre_Borges 

The error was that you can't reuse parentheses inside {{ }}.
Try the code below:

{% assign image = product.images[1] | img_url: 'large' %}
{% if product.media.size > 1 %}
{% capture image_html %}
  <img src="{{ image }}" alt="{{ product.featured_image.alt | escape  }}">
{% endcapture %}
{{ product_description | replace: 'Como Usar?', image_html }}
{% endif %}

View solution in original post

Replies 11 (11)