Applying img_url filter to string variable

Hi,

I have a custom metafield which populate URLs of the several images separated by comma, for example, "https://cdn.shopify.com/s/files/1.jpg, https://cdn.shopify.com/s/files/1.jpg ".

I wanted to apply img_url filter to these URLs so I wrote the code like below(example):


{% assign images = custom_fields | split: "," %}

{% assign image_url = images[0] | img_url: '100x100' %}
<p>{{ image_url }}</p>

This code shows me the default Shopify link for no images.

I tried file_img_url filter instead but same result.

How can I get resized image link from string variable?

Regards,

Toby

Since you’re not supplying a proper image object, the system does not quite understand you.

However, if you do it like this:

{% assing filename = "file.png" %}
{{ filename | file_img_url:  "100x" }}
{{ filename | asset_img_url: "100x" }}

You will get something like:

//cdn.shopify.com/s/files/1/1105/5070/files/file_100x.png?737
//cdn.shopify.com/s/files/1/1105/5070/t/1/assets/file_100x.png?743
 

The image must be in your files / assets for this to work (the system will generate those URLs even if there is no actual file though).