area17/twill-image
Twill Image adds responsive image rendering to Laravel's Twill CMS. It generates picture and source markup with named crops, srcset breakpoints, lazy loading, and low-quality placeholders, so editors can manage media in Twill while front-end images stay fast and correctly sized.
composer require area17/twill-image. The package targets Laravel 11/12 (12.x support was added in v2.1.0) and pairs naturally with Twill, but also works in a plain Laravel app if you provide a media model.php artisan vendor:publish --tag=twill-image-config. This gives you config/twill-image.php — the single place for breakpoints, formats, and transformer settings.area17/twill-image-local) or a remote/cloud one (Imgix). The transformer is what turns a media record + crop + dimensions into actual URLs.<img> in a hero block with the package's responsive image output. Render one image, pass a crop/aspect ratio, and confirm you get a <picture> with srcset for the configured formats. That validates the whole install (config → media model → transformer → URL generation) in one step.Where to look first: config/twill-image.php, then the package's Blade component(s) and README section on the transformer. Do not start by editing CSS; get a URL rendering out of the transformer before styling anything.
srcset widths and output formats (e.g. webp, avif, jpg fallback) once, then reuse them everywhere. Per-page overrides should be rare.HasMedias integration. In Twill models, attach media via the media trait and reference the role/collection when rendering. In non-Twill apps, wrap your own model and expose the same width/height accessors so the component stays agnostic.loading="lazy" and, where supported, a low-quality placeholder or blur-up. Treat these as component props, not hard-coded attributes, so above-the-fold heroes can opt out of lazy loading.APP_ENV or a dedicated env var.config/twill-image.php in production, run php artisan config:clear (and config:cache if you cache). Stale config is the most common "nothing changed" bug.src or exceptions on render. Check that a transformer is bound and its driver is installed before debugging the media model.localhost cannot be rendered server-side for external services — this is why local dev often needs the local transformer.srcset needs real aspect ratios. If your media has no width/height (e.g. not yet processed), crops compute wrong or fail. Ensure dimensions are persisted/available, or generate them on save.<picture> source order is significant. Browsers pick the first matching source; ordering formats from best (avif/webp) to fallback (jpg) matters. If a format seems ignored, check ordering and the type attribute.loading="lazy"; make it a prop and leave hero images eager.src/srcset from the component and open a single URL directly in the browser. If the transformer returns a 404/403, the issue is transformer config, not the package.How can I help you explore Laravel packages today?