Download the PHP package voskobovich/yii2-dynamic-image without Composer
On this page you can find all versions of the php package voskobovich/yii2-dynamic-image. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download voskobovich/yii2-dynamic-image
More information about voskobovich/yii2-dynamic-image
Files in voskobovich/yii2-dynamic-image
Package yii2-dynamic-image
Short Description Tools for generating image sizes upon customer request and upload image on server for Yii2
License MIT
Homepage https://github.com/voskobovich/yii2-dynamic-image
Informations about the package yii2-dynamic-image
Yii2 Dynamic Image
A toolkit to resize and crop images on the fly as specified in a GET request.
Support
See example
Directory structure
This toolkit requires your images to be organized in a specific manner.
A certain directory is the root:
uploads/images
Images that belong to certain entities (articles, users, etc.) are located in directories that correspond to those entities and their ids:
uploads/images/article/123
uploads/images/user/456
Every image should have an alphanumeric name (usually some kind of hash) and a proper extension:
uploads/images/article/123/acbd18db4cc2f85cedef654fccc4a4d8.jpg
uploads/images/user/456/37b51d194a7513e45b56f6524f2d51f2.png
Web Package
Getting images
Suppose the original image is available at this URL:
and you need it resized to 300x400 pixels. Simply add the desired dimensions to the name of the image as shown below:
The image will be resized proportionately and excess cropped. Not bad, right?
But what if only one of the dimensions is significant, and the other one is not? In this case, you need to set the non-significant dimension to zero:
or
Placeholder
The system can be configured to work with placeholders to serve when the image is not available. Placeholder file is usually named placeholder.png
. There are two kinds of placeholder - general and entity-specific. General placeholder is placed into the root directory, entity-specific placeholder is placed into the entity directory:
http://example.com/uploads/images/placeholder.png
http://example.com/uploads/images/article/placeholder.png
With this configuration, article images have their own specific placeholder, while user images fall back to the general placeholder. Requesting a non-existent user image will return the general placeholder (http://domain.com/uploads/images/placeholder.png
), while requesting a non-existent article image will return the entity-specific article placeholder (http://domain.com/uploads/images/article/placeholder.png
).
Uploading images
To upload a image you need to send a multipart/form-data POST request:
The response will contain
API Package
Getting images
After configuration the answer API you get 4 new attribute.
Now on the client you can do so
Uploading images
To upload a image you need to send a multipart/form-data POST request:
The response will contain
Installation
The preferred way to install this extension is through composer.
Either run
or add
to the require section of your composer.json
file.
Usage
Web Package
Use the package for voskobovich\image\dynamic\web.
Create and configure your controller.
API Package
Use the package for voskobovich\image\dynamic\rest.
Configure your controller as described above.
Configure ImagePathMap component in your config file.
Web server configuration
Nginx
Apache
All versions of yii2-dynamic-image with dependencies
yiisoft/yii2 Version ~2.0.0
yiisoft/yii2-imagine Version ~2.0.0
voskobovich/yii2-base-toolkit Version ~1.0.0