Welcome to the Liquify Community

Updated 4 weeks ago

li-settings:image filters?

Is there a way to add a filter to li-settings:image so that I can set a max width? I have a client setting images too large for the site and they're slow to load
J
f
j
20 comments
Hey @fergie77, thats not possible with li-settings:image, as far as I'm aware. But you can do a workaround:

You create a li-settings:custom="image" with the following json:

{
"type": "image_picker",
"id": "image",
"label": "Image"
}

Then you can put the following on the image:

li-object:src="section.settings.image | image_url: width: 500"
li-object:alt="section.settings.image.alt"
Aw that’s perfect, thank you!
I'm getting this error, what have I done wrong?
Can you send me the shopify code? Is the image in a block? :)
Two secs I'll get
It's in a section, not a block
Ah, nevermind. You can't use image_url, but img_url. I know it's deprecated, but it seems to work with Images from the file directory.

So instead of:
section.settings.image | image_url: width: 500

You use:
section.settings.image | img_url: 'small'

You can see the sizes here: https://shopify.dev/docs/api/liquid/filters#img_url
You also can use custom values, so you can still choose freely how large the image should be
Thats strange because docu says you can use it on on image objects
Working with img_url on my end! That is weird
Is there maybe some blank character or anything? If I write it from scratch it seems to also work with image_url
I just copied directly from your message to test
Does it matter if there is a space after width: or image_url: ?
I'm sure I had that, will give it another go!
Yea its weird. When I copied the code from your section, it didn't work. But when I wrote it from scratch, it worked. So there might be some hidden blank space or formatting that's the problem.
Okay it's working for me now with image_url! Must have something hidden in there yea
Thanks for the help!
good to know. But very strange
Add a reply
Sign up and join the conversation on Discord