github timnarr/kirby-imagex 0.6.0-beta.1

pre-release3 hours ago

Beta for Kirby 6. Install it with composer require timnarr/kirby-imagex:^0.6@beta. For Kirby 5, stay on 0.5.x.

Added

  • New stack plugin option: the name of a Kirby 6 template stack in your <head>. When set, the imagex-picture snippet pushes its <style> element (art-direction and focus styles) into it instead of rendering it next to the <picture>. Defaults to null, which keeps the previous output.
  • New preload snippet option: adds <link rel="preload" as="image"> elements with imagesrcset/imagesizes for critical images to the stack. One format per source (respecting compareFormats), and art-directed sources get mutually exclusive media conditions, so only the image <picture> actually uses is fetched. The exclusions use the Media Queries Level 4 range syntax where possible: (width >= 800px) and (min-width: 800px) are negated as (width < 800px). Requires loading: 'eager' and the stack option, both validated with a descriptive error.
  • New public Imagex::getPreloadLinks() and Imagex::getStack() getters. The imagex-picture-json snippet outputs the links under the new top-level preloadLinks key (omitted when empty).
  • New formats snippet option: overrides the global formats for a single image, e.g. ['webp'] for animated GIFs (Kirby converts them to a still AVIF) or [] for no modern formats. null (default) uses the global option.

Fixed

  • Bug: With compareFormats and an art-directed image, the art-directed image could be ignored. <source> elements were grouped by format, so when the art-directed image skipped AVIF but the main image didn't, the default AVIF <source> (no media) came first and always matched in AVIF browsers. <source> elements are now grouped by source: each artDirection entry in all its formats, then the main image in all its formats. The order of <source> elements changes for every art-directed <picture> with more than one format; browsers still pick the same image, except in the buggy case above. Migration: if your CSS or JavaScript relies on the position of <source> elements, select them by media or type instead.
  • An artDirection entry with its own image now keeps every format its own comparison keeps, even if compareFormats skipped that format for the main image. Previously a format skipped for the main image was skipped for every source.
  • Files Kirby can't resize (e.g. SVGs) are rendered as a plain <img> with the original file as src. Previously every format got a <source> listing the original SVG under every width, with a wrong type like image/avif. compareFormats is skipped for them.

Changed

  • BREAKING: An artDirection entry using a file Kirby can't resize (e.g. an SVG), directly via its own image or by falling back to the main image, now throws a descriptive InvalidArgumentException. Previously it rendered <source> elements that repeated the original file under every width and format. Migration: give the entry its own resizable image (JPEG, PNG, WebP, AVIF …), or leave out artDirection for such files.
  • BREAKING: Kirby 6 is now required (extra.kirby.compatible is ^6.0). Kirby 5 is no longer supported. Migration: upgrade your site to Kirby 6, or stay on 0.5.x while you are on Kirby 5. A conflict with getkirby/cms < 6.0 keeps Composer from installing this version into a Kirby 5 project. No option names, snippet variables or output changed.
  • BREAKING: PHP 8.3 is now the minimum version (Kirby 6 requires it). PHP 8.2 is no longer supported.
  • README, examples and error messages use the Media Queries Level 4 range syntax, e.g. (width >= 800px) instead of (min-width: 800px). Your own media strings are output unchanged.

Don't miss a new kirby-imagex release

NewReleases is sending notifications on new releases.