Download the PHP package bst27/laravel-image-proxy without Composer
On this page you can find all versions of the php package bst27/laravel-image-proxy. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download bst27/laravel-image-proxy
More information about bst27/laravel-image-proxy
Files in bst27/laravel-image-proxy
Package laravel-image-proxy
Short Description A Laravel image proxy to cache, minify and modify images very easily.
License MIT
Informations about the package laravel-image-proxy
Laravel Image Proxy
A Laravel image proxy to cache, minify and manipulate images very easily.
Features
- Automatic image compression / minification
- Automatic caching of images on host and client side
- Flexible storage options (local, S3, SFTP etc.)
- Optional: image manipulation (resizing etc.)
- Optional: custom image filename in URL
- Easily extendable with custom strategies for image manipulation
Installation
Per default spatie/image-optimizer is used to compress images. So make sure you install the required dependencies as described in their docs.
Usage
Use the global helper function proxy_image() to generate a secure image URL:
This will automatically minify and cache the image and generate something like this:
You can also define a strategy and filename for image manipulation:
This will use the default strategy for image manipulation, keep the given filename
and generate something like this:
Manipulation Strategies
To manipulate images, you can configure different strategies in config/image-proxy.php. The DefaultManipulator strategy uses spatie/image-optimizer to compress images.
Each strategy class must implement the ImageManipulator contract. You can add your own image manipulation strategy easily:
- Implement the contract interface
- Add your manipulator to the
manipulation_strategyarray of theimage-proxy.phpwith a unique strategy key. - Start using it by calling
proxy_image()with your strategy key.
Endpoints
Two routes are registered automatically:
-
Short URL:
/img/{token}.{ext} - Named URL:
/img/{token}/{filename}
URLs to these routes are generated via proxy_image() and require a valid encrypted payload token.
You can customize them via the config.
Storage
Flysystem is used to offer flexible storage options. Per default
the original images are read from the local storage disk. The cached images are stored on the local storage disk, too.
You can customize the used storage disks using the plugin config or environment settings.
Configuration
Check image-proxy.php for default config. You can customize config via environment variables or publish the config file:
This will create config/image-proxy.php.
Tests
To run tests, you can execute the following command:
All versions of laravel-image-proxy with dependencies
spatie/image-optimizer Version ^1.8
ext-openssl Version *