craft theme, collection images are sized appropriately but are causing major issues

Topic summary

A Shopify store owner using the Craft theme is experiencing performance issues and poor Cumulative Layout Shift (CLS) scores caused by collection tile images, despite the images being properly sized. The images were optimized for mobile users but negatively impacted site performance.

Initial Problem:

  • Collection images (1600x1600) with srcset and sizes attributes were causing performance degradation
  • Tests confirmed images were properly sized, but CLS issues persisted
  • Various optimization attempts (smaller sizes, JPG format, 800x800 dimensions) didn’t resolve the issue

Solution Implemented:
Another user suggested editing the main-collection-banner.liquid file by removing the srcset and sizes attributes from the image tags, leaving only the basic src attribute with a fixed width of 750px.

Outcome:

  • Performance score improved by 20 points (reaching 67)
  • The store owner confirmed the fix worked after implementing the code changes

Remaining Issue:
The user now has a secondary concern about managing hover effects versus static display, but hasn’t received a response yet on this new question.

Summarized with AI on October 29. AI used: claude-sonnet-4-5-20250929.

I have created collection tile images mainly for mobile users, but after I loaded them, my website performance took a hit, and they seem to be giving me poor cls. I ran the test, and it came back with properly sized images.

example: Dog Mats, Dog Boned Shaped Mats, Pet Welcome Mats

How do I fix this? I have loaded smaller images, I have loaded jpg, instead of png, I have loaded 800x800 and I still get this.

www.created4ucreations.com

Hi @tabel69 ,

May I suggest to update code these steps:

  1. Go to Store Online-> theme → edit code

  1. Sections/main-collection-banner.liquid
    3.Remove 2 attributes( srcset and sizes) of images.

I will try this today… and get back to you. And thank YOU if this works!! Either way… thank you for even responding… I appreciate the guidance!

-tina

I did it… and I still get the same result. Matter of fact my performance worsen. And they still show up on my report.

Maybe I need to give it more time to take?

Any other suggestions? I really like having the collection tile images… I think it helps via when using the mobile version but maybe I need to remove them and just use text squares.

Hi,

Could you give the content of this file? I will help you remove it.

I’m not sure what you mean by “content of this file”. www.created4ucreations.com if you go via mobile device you will see my collection images. It is those images that seems to be the issue.

{% comment %}theme-check-disable ImgLazyLoading{% endcomment %}
{{ ‘component-collection-hero.css’ | asset_url | stylesheet_tag }}

{%- style -%}
@media screen and (max-width: 749px) {
.collection-hero–with-image .collection-hero__inner {
padding-bottom: calc({{ settings.media_shadow_vertical_offset | at_least: 0 }}px + 2rem);
}
}
{%- endstyle -%}

{{ 'sections.collection_template.title' | t }}: {{- collection.title | escape -}}

{%- if section.settings.show_collection_description -%}

{{ collection.description }}
{%- endif -%}

{%- if section.settings.show_collection_image and collection.image -%}

<img

src=“{{ collection.image | image_url: width: 750 }}”

alt=“{{ collection.image.alt | escape }}”
width=“{{ collection.image.width }}”
height=“{{ collection.image.height }}”

{%- endif -%}

{% schema %}
{
“name”: “t:sections.main-collection-banner.name”,
“class”: “section”,
“settings”: [
{
“type”: “paragraph”,
“content”: “t:sections.main-collection-banner.settings.paragraph.content”
},
{
“type”: “checkbox”,
“id”: “show_collection_description”,
“default”: true,
“label”: “t:sections.main-collection-banner.settings.show_collection_description.label”
},
{
“type”: “checkbox”,
“id”: “show_collection_image”,
“default”: false,
“label”: “t:sections.main-collection-banner.settings.show_collection_image.label”
},
{
“type”: “color_scheme”,
“id”: “color_scheme”,
“label”: “t:sections.all.colors.label”,
“default”: “scheme-1”
}
]
}
{% endschema %}

I think I figured out what you meant… so I copied and pasted the whole section. And thank you!!!

Here is the whole section… I think this what you were asking for. Edit
as you seem fit! And a HUGE THANK YOU!!!
-tina


{% comment %}theme-check-disable ImgLazyLoading{% endcomment %}
{{ ‘component-collection-hero.css’ | asset_url | stylesheet_tag }}

{%- style -%}
@media screen and (max-width: 749px) {
.collection-hero–with-image .collection-hero__inner {
padding-bottom: calc({{ settings.media_shadow_vertical_offset |
at_least: 0 }}px + 2rem);
}
}
{%- endstyle -%}

{{
‘sections.collection_template.title’ | t }}:
{{- collection.title | escape -}}

{%- if section.settings.show_collection_description -%}

{{
collection.description }}

{%- endif -%}

{%- if section.settings.show_collection_image and collection.image -%}

src=“{{ collection.image | image_url: width: 750 }}”

alt=“{{ collection.image.alt | escape }}”
width=“{{ collection.image.width }}”
height=“{{ collection.image.height }}”

{%- endif -%}

{% schema %}
{
“name”: “t:sections.main-collection-banner.name”,
“class”: “section”,
“settings”: [
{
“type”: “paragraph”,
“content”:
“t:sections.main-collection-banner.settings.paragraph.content”
},
{
“type”: “checkbox”,
“id”: “show_collection_description”,
“default”: true,
“label”:
“t:sections.main-collection-banner.settings.show_collection_description.label”
},
{
“type”: “checkbox”,
“id”: “show_collection_image”,
“default”: false,
“label”:
“t:sections.main-collection-banner.settings.show_collection_image.label”
},
{
“type”: “color_scheme”,
“id”: “color_scheme”,
“label”: “t:sections.all.colors.label”,
“default”: “scheme-1”
}
]
}
{% endschema %}

My performance bumped up to a 67… so I gained 20 points in the right direction! Thank you!! Now I have one more issue… that maybe you know the work around too. I have looked to see how to maybe changed it from hoover default to static but I don’t see it.

How do I mange this or code it?

But first - let me say thank you for your help. Sorry for the delay, I had grandchildren for past week and half, and working on my website had to take a back seat.

-tina