Download the PHP package jmoguelruiz/yii2-resource-image without Composer
On this page you can find all versions of the php package jmoguelruiz/yii2-resource-image. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package yii2-resource-image
Welcome to the yii2-resource-image wiki!
This is a component for yii2, to manage the images to upload in server and the generation of paths easiest.
Override
I think that the url path is formed for five parts: root, base, resource, size, name. For example:
- root : http://project-template.dev
- basePath : images/dev
- resource : player
- size : thumb
- name : image_1485386176.jpg
And all togueter is http://project-template.dev/images/dev/player/thumb/image_1485386176.jpg
For that reason, I built this component to configure each part and generate the url most easy, I included many functions that help you to manage the images files.
Each part has its own configuration.
Root
This part is for root of url, the follow code is the default configuration:
When isWebUrl
is true, generate http://project-template.dev/
otherwise is /Users/josemoguel/Documents/fuentes/project-template/frontend/web
Basepath
This part is automatically configured from environment that you are running.
You can set the environment if you want, there are three environments by default dev,test,prod
.
Resource
The resource that belongs to the image, player, user, gamer for example.
When isTemp
is true
, add to the resource the prefix _temp or if you have one configured player_temp
, set isTemp = true
for process the image, and later save in the real directory.
Size
You can have many sizes of the image to save.
Name
You can assign the name of image.
If you put concatTime = true
will concat the time in the name image resolving the problem with cache. image_1485386176.jpg
.
Installation
The way prefer is composer:
composer install jmoguelruiz/yii2-resource-image
Or adding in you composer file.
"jmoguelruiz/yii2-resource-image": "1.0.*"
In config/main inside of component put the follow code:
You should add the file ResourceImage in your common\components folder, overriding this extension, for configure the follow options.
Create the folders where the images will be saved and configuring your enviroments enviroment/index.php
for permissions.
Usage
Generating a url.
Saving one image file.
Save image in many sizes.
Save images for sizes.
Get web url
Get default web url
ResourcePath
Generating new path you can access the data of the model.
Contributions
You can use this component if you want can contribute send email to [email protected].
From community to community...