no. the w/h is not fixed in the config ā you just let srcset know you want to use focuscrop in some cases. thatās what the config value resize taking a callback does.
the new thing you need to create the the needsCrop filemethod in a tiny plugin of your own. it needs to check if a file needs focuscrop (based on template, name of field etc.) and use the width provided from the srcset plugin to calculate the width and height for it (the $c that will be used in the callback). or return null.
basiclly think of the srcset plugin as an issuer of thumbs. it does not create them itself. the default just happens to be the resize method used in the callback.
btw i did it like that so my thumb-image-optim plugin will be executed (on resize).
All of them. I mostly do it with hero banners accross the top hence the large size above, but honestly, it could be any image, from anywhere, from a field or directly from the file iteself.
ah ok. but thats fine. the filemethod is accessing the meta-data file (aka content file of file).
edited: i updated the sourcecode above to reflect the dynamic name of the field.
Unfortunately this wonāt work, because the Focus plugin wonāt calculate any height based on the width. Both values (width and height) are passed as arguments like ā¦
<?= $image->focusCrop(200, 300) ?>
Using focusCrop() within the resize option might work if you can calculate the width and height by yourself, maybe based on the image file template (untested) ā¦
if ($file->page()->intendedTemplate() == 'myTemplate') { ... }
Of course you can move your calculation to a custom file method like the needCrop() one above, but you will need to calculate the width and height by yourself.
Thanks @flokosiol and @bnomei for the guidance but I fear it might be a little beyond my powers. Iāll give it a go though.
@flokosiol I did notice that the K3 version doesnt seem to return the X and Y values when you use the image as a background and want to position it with background-position..
Edit: potentially my mistake, I donāt think i ran it through ->tofile()