Open reggi opened 9 years ago
collection.image
returns null
if there's no image present. It's not ideal because it relies on using a conditional that has nothing to do with the variable that we need and it's object specific.
{% assign image_avail = collection.image %}
{% assign image = collection | img_url: "master" %}
This was originally posted here https://github.com/Shopify/liquid/issues/497
This bug featured still here?
assign file_url = 'image.png' | file_url // always return string.
if file_url
echo 'This image file is true' // always print this line, lol.
else
echo 'No image'
endif
Yes this is still a problem. There is currently no way to check if the file called by file_url or file_img_url actually exists :(
If you attempt to pull the
img_url
from a shopify object that doesn't have an image you get a url back. I would expect to get anull
orfalse
.If you attempt to get the
img_url
from any kind of variable you get a string backAll will return back
"//cdn.shopify.com/s/assets/admin/no-image-master.gif"
Here's a empty
img_url
with all the sizes.This is the output
So the only consistent thing is
no-image
.Working example of URLS returned
Here's an example of everything going right, a collection with a image present.
You can see the path URL is a little different for the missing images too.