Download the PHP package tuupola/slim-image-resize without Composer
On this page you can find all versions of the php package tuupola/slim-image-resize. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download tuupola/slim-image-resize
More information about tuupola/slim-image-resize
Files in tuupola/slim-image-resize
Package slim-image-resize
Short Description Image Resize Middleware for Slim Framework
License MIT
Homepage https://github.com/tuupola/slim-image-resize
Informations about the package slim-image-resize
Image Resize Middleware for Slim
This middleware implements automatic image resizing based on image filename.
Install
You can install latest version using composer.
Configuration
Configuration options are passed as an array. There are no mandatory parameters.
You can configure the allowed image extensions and cache folder. Cache folder must be writable by webserver process. Image quality applies only for jpg images. Example options shown below are also the default options used by the middleware.
Caching
For caching to work you also must add the following to your .htaccess file. These rules should be added before Slim rewrite rules. Folder name must be the same you passed in as middleware configuration option. With caching rewrite rules in place only first request is served by PHP. All subsequent requests are served with static file from cache folder.
If your Slim application is installed in to a subfolder use the following rewrite rule instead. This example assumes the subfolder is called example
.
Usage
With middleware configured you can create different sizes of images by altering the filename.
HTML above will produce the following images.
Security
By default it is possible to create any size image. If images are also cached you should restrict which sizes middleware is allowed to create. Otherwise it is possible to make requests arbitary number of different sizes of images.
If you have arbitary number of different sizes it is also possible to sign images with secret key.
You must include the signature in the image name.
Signature for above image was generated with following code.