A Shopify store owner reports product images displaying as grey boxes on mobile devices, despite acceptable site speed (54/55). The issue affects product thumbnails, collection page first images, and homepage hero banners.
Root Cause Identified:
A missing closing quotation mark in the HTML class attribute within the theme code was discovered. The malformed code appeared in the image.load.liquid snippet.
Troubleshooting Steps Taken:
Added missing quotation mark after square{% endif %} in the class attribute
Fixed hanging comma in data-srcset attributes by modifying the img_set capture block
Adjusted code to properly format responsive image srcset values
Current Status:
Partially resolved - most images now load correctly, but the first item in each collection still shows no image on mobile (not even grey boxes). Desktop displays properly.
We are having issues with images for products loading on mobile devices. According to the admin page of our site, site speed is around 54/55 so the site itself is not snail pace. But for some reason the images on mobile just don’t load. The thumbnails are just grey boxes, no matter how many times I refresh the page. The website is advancedacoustics-uk.com. Is there something we need to chance with the code. We’ve knocked the size of the image files down. Try to attach a screenshot but this thing won’t let me.
I think I have found the line, all the quotation marks after this line are black telling me there’s one missing? When I put a quotation mark at the end it automatically adds another as if that is in the wrong place.
class="{% if alt contains ‘3D’ %}easySpanOpacity {% endif %}{{ screen }}{% unless nopad %}nopad {% endunless %}js lazyload {% if background or swatch %}lazybackground {{ position }} {% endif %}img-align {% if img_src.aspect_ratio > 1 %}landscape{% elsif img_src.aspect_ratio < 1 %}vertical{% else %}square{% endif %} {% if image.alt contains ‘3D’ %}style=“opacity:0.3;” {% endif %}
So I have done this
class=“{% if alt contains ‘3D’ %}easySpanOpacity {% endif %}{{ screen }}{% unless nopad %}nopad {% endunless %}js lazyload {% if background or swatch %}lazybackground {{ position }} {% endif %}img-align {% if img_src.aspect_ratio > 1 %}landscape{% elsif img_src.aspect_ratio < 1 %}vertical{% else %}square{% endif %}”{% if image.alt contains ‘3D’ %}style=“opacity:0.3;” {% endif %}
However there is still no change with the grey boxes showing instead of images. Same problem is with the first picture of every collection page. Grey boxes everywhere!
I do not have iPhone and can only use IOS Simulator and there only the first product in collection is not loaded properly.
It may be because data-srcset properties are not 100% percent proper – they have hanging comma at the end, but I need to see the entire snippet source code to suggest anything.
So it should either output srcset in 1x/2x notation, or content of the img_set variable/snippet parameter.
The code of product.images.liquid which you’ve shared initially does not use any img_set but it’s code code for product page as far as I can see (but it does not match the actual output as well).
Which should either output data-srcset in 1x/2x notation, which is not happens on site,
or content of the img_set variable/snippet parameter, but none of the code you’ve shared calculates this variable.
So my only guess is that this img_src is calculated somewhere in the image.load snippet but you have not shared the entire code of the snippet?
I must add that in my opinion the theme uses responsive images improperly – they do not supply the sizes parameter which means that the biggest image is always used and you may as well remove the srcset/data-srcset at all…
That seems much better however for the first item in every collection we now have no images at all showing, not even a coloured box. Desktop is all fine, the issue is still with mobile.
As for the issue with the theme they have brought out a new update but since the last update we have done a little custom work and I’m not sure how much of it we will loose such as custom add to cart colour, additional tabs in the product description, 3d images. We are on 2.0.4 and it’s now 5.0.1