Download the PHP package joassanon/image-optimizer without Composer
On this page you can find all versions of the php package joassanon/image-optimizer. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download joassanon/image-optimizer
More information about joassanon/image-optimizer
Files in joassanon/image-optimizer
Package image-optimizer
Short Description On-demand image optimization endpoint for Laravel
License MIT
Informations about the package image-optimizer
# Image Optimizer / Optimized Image
This repository contains two related packages:
@joassanon/optimized-image— a React component for responsive optimized image deliveryjoassanon/image-optimizer— a Laravel image optimization endpoint that serves/img
The React component is built to work with the Laravel backend in the same repository. It generates responsive srcset/sizes markup and calls /img with query parameters.
What is included
src/OptimizedImage.tsx— React componentsrc/index.ts— package exportssrc/OptimizedImage.test.tsx— Vitest-powered test suitecomposer.json+ Laravel service provider + controller — backend endpoint implementation
Installation
React package
or
Laravel backend
Install the Laravel package as a dependency:
If your Laravel app does not auto-discover providers, register it manually:
Publish config if required:
Backend endpoint
The backend exposes a single route at /img.
Supported query params:
src— local image path, e.g.images/products/shoe.jpgw— width in pixelsq— quality (10–95)fm— optional output format (webp,avif,png,jpeg)fit— optional fit mode, defaults tomax
Important: the current Laravel endpoint only accepts
srcvalues beginning withimages/and expects the file to exist on the configured filesystem disk.
React usage
Notes
srcshould be a local storage path, not an external URL, when using the bundled Laravel backend.- The component builds
/img?src=...&w=...&q=...for each width. - If
formatis omitted, the backend negotiates the format from the browserAcceptheader.
Props
| Prop | Type | Default | Description |
|---|---|---|---|
src |
string |
required | Local image path passed to /img, e.g. images/photo.jpg |
alt |
string |
'' |
Alternative text for the image |
widths |
number[] |
[320, 480, 768, 1024, 1366, 1600, 1920] |
Widths used to generate srcset |
sizes |
string |
100vw |
Value for the sizes attribute |
quality |
number |
75 |
Optimizer quality setting |
format |
string |
undefined |
Optional output format sent as fm |
priority |
boolean |
false |
When true, uses loading="eager" |
placeholder |
string | null |
null |
Optional blurred placeholder image URL |
className |
string |
'' |
CSS class name for the rendered image |
style |
React.CSSProperties |
{} |
Inline styles for the rendered image |
Build & test
Peer dependencies
react@>=18react-dom@>=18
License
MIT
All versions of image-optimizer with dependencies
illuminate/support Version ^10.0
intervention/image Version ^2.7
spatie/image-optimizer Version ^1.8