mj-zana / media
Responsive images for Zana applications: WebP and AVIF variants, metadata stripped, alt text per locale
v2.4.0
2026-10-26 14:55 UTC
Requires
- php: ^8.5
- ext-gd: *
- mj-zana/core: ^2.4
- mj-zana/filesystem: ^2.0
- psr/http-message: ^2.0
Requires (Dev)
- nyholm/psr7: ^1.8
- phpstan/phpstan: ^2.1
- phpunit/phpunit: ^11.5
Suggests
- ext-exif: To apply the orientation phones record in JPEG photos
Provides
None
Conflicts
None
Replaces
None
README
Responsive images for Zana applications: WebP and AVIF variants in several widths, metadata stripped, and alt text per locale. Uses GD only.
composer require mj-zana/media
Register MediaServiceProvider and configure two disks
(filesystem): a public one
with a url, and a private one for the originals.
// config/media.php return ['disk' => 'public', 'private_disk' => 'private', 'widths' => [480, 960, 1600]];
$media = $library->store($request->getUploadedFiles()['photo'], ['en' => 'The team', 'fr' => 'L’équipe']); $post->imageJson = json_encode($media->toArray());
With mj-zana/view, a template prints the image with
<?= $this->picture($media, sizes: '(min-width: 60em) 50vw, 100vw') ?>:
a <picture> with AVIF and WebP sources, a JPEG fallback, width and height,
lazy loading, and the alt text in the current locale.
Rules
- Originals stay private. Only the variants are published.
- Metadata is gone. Variants are re-encoded, so EXIF data such as the
GPS position and camera serial is never published. JPEG orientation is
applied first (with
ext-exif). - Widths: no variant is wider than the original.
- Alt text is required in at least one locale.
- Accepted formats: JPEG, PNG, WebP, GIF and AVIF, up to 50 megapixels.
License
MIT