On frontend, gallery image files are loaded according to screen width even if an intermediate size has been selected because all srcset are included, resulting in huge bandwith for large screen.
Only srcset BELOW selected size should be included here.
I actually think I was wrong and the issue is not full srcset, but rather the combination of width / height attribute values and width / height gallery CSS and full srcset:
That’s why I guess setting width and height attributes with selected file size dimensions is better.
You force the file you need and you play with CSS sizes.
Sorry to insist, but this is pretty critical to me in some cases, and I think I found out the issue:
It looks like sizes attribute is not generated for galleries images in addition to srcset, like you do for standard images.
So even on mobile, full size images are loaded.
In addition to this, I think we could go even further by taking into acount the number of columns in gallery to generate sizes
Because even with sizes defined as you do in standard images, big size images will be loaded on desktop even if displayed on 4 columns, so with small size (sizes based on screen widths).
So maybe for each breakpoint, each size in sizes should be divided by the number of columns?
Thanks for bringing this up again and sorry for not responding to it, it somehow was missed on my list.
I’ll review this in the next few days and will update accordingly.