Added
- New
focussnippet option (defaultfalse). Applies Kirby's nativefocuscontent field (the same onethumb(['crop' => true])already uses for cropping) asobject-positionon the<img>, plusobject-fit: cover. Falls back to'center'when no focus point is set. NewresolveFocusValue()helper, backed by a newisValidCssPositionValue()validator: sincefocusis Panel-editable content rather than developer-controlled input, its value is validated against the shapeobject-positionactually accepts before being embedded in generated CSS, falling back to'center'on anything else — closing a CSS/HTML-injection path into the<style>tag described below. - New
Imagex::getArtDirectionStyles()method.artDirectionsources only ever control which thumbnail the browser picks — the rendered<img>keeps the baseratio/focus point regardless of which source matched. This method returns@media-scoped!importantCSS (targeting the<img>'sid, auto-generated unless one is set viaattributes.img) for everyartDirectionentry whoseratioor (withfocusenabled)imageactually differs from the default, so the<img>stays visually in sync with the active source. Theimagex-picturesnippet renders this automatically in a<style>tag;imagex-picture-jsonexposes it as theartDirectionStyleskey. Result is memoized per instance. Theidlookup checks the active loading mode before falling back toshared, matchinggetImgAttributes()'s own resolution order. - New
tests/bootstrap.php, wired up viaphpunit.xml'sbootstrapattribute. SetsKirby\Cms\App::$enableWhoops = false— needed now thatresolveFocusValue()is tested against a realKirby\Cms\File, which lazily bootstraps a defaultAppinstance for blueprint resolution and would otherwise register Whoops as a global error/exception handler for the rest of the test run.
Fixed
- Bug:
compareFormatscould serve a larger, non-optimal format when 3+ formats were configured (e.g.formats: ['avif', 'webp']combined withaddOriginalFormatAsSource: true). The format-skip logic only skipped the format immediately preceding the smallest one, not every format before it, so browsers could still pick a larger format listed earlier. Fixed by extracting the (already-correct) skip logic used for art-directed sources into a sharedisFormatSkippable()helper, now used by both the default and art-directed source paths. Imagexconstructor now validatesratio,srcset, andcompareFormatsthe same way it already validatesimageandloading, throwing a descriptiveInvalidArgumentExceptioninstead of a genericTypeErrorwhen instantiated directly with missing/invalid options.
Changed
srcHandler()now accepts an optional$customLazyloadingoverride parameter instead of always re-reading thetimnarr.imagex.customLazyloadingconfig option;Imagexpasses its already-cached value.
Full Changelog: 0.3.0...0.4.0