Getting an image as an object for an image in the assets directory

Highlighted
Shopify Partner
1 0 1

Hello!

I want to use a snippet `bgset.liquid` that came with my theme for generating a list of different image sizes for an image. To do this I need an images object. This image is being hardcoded into the page template. I can do this if I upload the image on the site;

{% assign imgObj = images['test-large.png'] %}

I was wondering if it's possible to do this with an image that lives in the `/assets` directory. Say something like;

{% assign imgObj = images['assets/test-large.png'] %}
1 Like
Shopify Partner
1343 22 204

Hey,

Not sure what you want to do in there but you can access an asset image with the asset_img_url filter.

Please have a look at the docs: https://help.shopify.com/en/themes/liquid/filters/url-filters#asset_img_url

https://sections.design tips, tricks & Shopify sections
0 Likes
New Member
4 0 0

I'm trying to do the same thing, and can't even get that snippet to work for pulling an asset from the Files section as an image object.

He's trying to references images in the assets/ folder as image objects so that we can access object properties and run useful performance related functions like the responsive-bg-image.liquid snippet.

There is no reference or documentation I can find on this whatsoever and it's so weird - the majority of images on my site are not product images so why isn't there a way to reference static assets as objects?

0 Likes