$file->resize()->srcset() should work?

I am trying to chain:


…as far as I can see resize() returns a file object. But this outputs nothing, where $file->srcset([x,y]) returns the proper srcset declaration.

I know this is a rather weird thing to do, but there is this huge image that srcset just ignores: won’t resize it, just spits the original as if it was really resized.

So I am trying to explicitly resize the image in a first step, then run srcset, see if that fixes it.

Difficult client


No, that will not work.

resize returns a FileVersion object, not a file object, but srcset is a file method.

If the images are too large, resize them on upload (via plugin or hook), or prohibit uploading of such large file right from the outset.

1 Like

Why do you want to resize it in the first place if srcset would then create resized versions anyways?

Something wrong with this image, srcset did not spit versions, but just the same original image with the size suffix, was trying to downscale the image before srcsetting. Will solve it some other way.