I've got a field that editors can add a number to which will make sure that images are all that width or height. The images are resized with CE Image.
I also want to be able to serve up different resolution versions of the image to be handled by srcset
.
I thought I could do something like this:
srcset="{exp:ce_img:single
src='{url}'
width='{width}'
url_only='yes'} 1x,
{exp:ce_img:single
src='{url}'
width='{exp:math formula='{width} * 2'}'
url_only='yes'
parse='inward'} 2x"
That does output a resized image, but the values are coming out wrong.
For instance, for a series of images where the width is set to 350, I'd expect the 2x value to be 750. Instead I'm getting:
data-srcset="/assets/img/sized/assets/img/content/Image1_350_262_85.jpg,
/assets/img/sized/assets/img/content/Image1_1187_890_85.jpg 2x"
data-srcset="/assets/img/sized/assets/img/content/Image2_350_262_85.jpg,
/assets/img/sized/assets/img/content/Image2_1187_890_85.jpg 2x"
data-srcset="/assets/img/sized/assets/img/content/Image3_350_233_85.jpg,
/assets/img/sized/assets/img/content/Image3_1335_890_85.jpg 2x"
data-srcset="/assets/img/sized/assets/img/content/Image4_350_239_85.jpg,
/assets/img/sized/assets/img/content/Image4_1301_890_85.jpg 2x"
data-srcset="/assets/img/sized/assets/img/content/Image5_350_233_85.jpg,
/assets/img/sized/assets/img/content/Image5_1409_939_85.jpg 2x"
i.e. the width values are a bit all over the place.
Anyone have any ideas about what might be going wrong or how to get the correct output?