2017 © Pedro Peláez
 

yii2-extension yii2-file-processor-module

Extension to upload and store files

image

vadymsemeniuk/yii2-file-processor-module

Extension to upload and store files

  • Tuesday, July 25, 2017
  • by Vadym Semeniuk
  • Repository
  • 1 Watchers
  • 0 Stars
  • 1,514 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 12 Forks
  • 0 Open issues
  • 8 Versions
  • 7 % Grown

The README.md

Total Downloads Latest Stable Version, (*1)

Yii2 file processor module

Extension to upload and store files, (*2)

Installation

The preferred way to install this extension is through composer., (*3)

Either run, (*4)

php composer.phar require --prefer-dist vadymsemeniuk/yii2-file-processor-module "*"

or add, (*5)

"vadymsemeniuk/yii2-file-processor-module": "*"

to the require section of your composer.json file., (*6)

Usage

Once the extension is installed, simply use it in your code by :, (*7)

./yii migrate --migrationPath=@vendor/metalguardian/yii2-file-processor-module/src/migrations

UploadBehavior

add this to behaviors of model, (*8)

'upload_image_id' => [
                'class' => \metalguardian\fileProcessor\behaviors\UploadBehavior::className(),
                'attribute' => 'image_id',
                'required' => false,
                'image' => true,
   ```

DeleteBehavior
--------------

add this to behaviors of model

for one attribute

'delete_image_id' => [ 'class' => \backend\components\DeleteBehavior::className(), 'attribute' => 'image_id', ],, (*9)


for array of attributes

'delete_media_files' => [ 'class' => \backend\components\DeleteBehavior::className(), 'attribute' => ['image_id', 'video_id'], ],, (*10)


UploadDeleteBehavior -------------- add this to behaviors of model

'upload_delete_image_id' => [ 'class' => \metalguardian\fileProcessor\behaviors\UploadDeleteBehavior::className(), 'attribute' => 'image_id', 'required' => false, 'image' => true, ```, (*11)

PNG Compression

To switch-on compression for png-images install https://pngquant.org. Then add to console controller action ImageCompressor::compressPngThumbs($path);, where $path is path to thumbnails folder and setup cron task from user which creates files, for example www-data(crontab -u www-data -e)., (*12)

Adding watermarks to thumbnails

To add watermark while creating FPM::ACTION_ADAPTIVE_THUMBNAIL, FPM::ACTION_THUMBNAIL or FPM::ACTION_CANVAS_THUMBNAIL config must be like this:, (*13)

'sliderThumb' => [
                        'action' => FPM::ACTION_THUMBNAIL,
                        'width' => 330,
                        'height' => 330,
                        'watermark' => [
                            'fileName' => $wmarkPath,
                            'point' => [
                                'x' => 0,
                                'y' => 0,
                            ],
                            'size' => [
                                'width' => 330,
                                'height' => 330,
                            ]
                        ],
                    ],

where 'point' (coordinates of point on originap image where to place watermark) and 'size' (size of watermark's thumbnail if it larger then original image) are optional, only 'fileName' is required. If watermark size is larger then original image - it will not be pasted into original image. To fix this - module will create thumbnail of watermark with original image size to fit it., (*14)

Change quality of images

To change quality of thumbnail you need to specify quality property in config:, (*15)

'thumbImage' => [
    'action' => FPM::ACTION_THUMBNAIL,
    'width' => 330,
    'height' => 330,
    'quality' => 75,
],

This property must be an integer in range from 0 to 100., (*16)

The Versions

25/07 2017

dev-master

9999999-dev

Extension to upload and store files

  Sources   Download

MIT

The Requires

 

by Ivan Pushkin
by Avatar Vadym Semeniuk

file extension yii2 upload

14/02 2017

1.0.2

1.0.2.0

Extension to upload and store files

  Sources   Download

MIT

The Requires

 

by Ivan Pushkin
by Avatar Vadym Semeniuk

file extension yii2 upload

19/01 2017

1.0.1

1.0.1.0

Extension to upload and store files

  Sources   Download

MIT

The Requires

 

by Ivan Pushkin
by Avatar Vadym Semeniuk

file extension yii2 upload

17/06 2016

0.0.2

0.0.2.0

Extension to upload and store files

  Sources   Download

MIT

The Requires

 

by Ivan Pushkin
by Avatar Vadym Semeniuk

file extension yii2 upload

17/06 2016

1.0.0

1.0.0.0

Extension to upload and store files

  Sources   Download

MIT

The Requires

 

by Ivan Pushkin
by Avatar Vadym Semeniuk

file extension yii2 upload

05/04 2016

dev-revert-2-png-compression

dev-revert-2-png-compression

Extension to upload and store files

  Sources   Download

MIT

The Requires

 

by Ivan Pushkin
by Avatar Vadym Semeniuk

file extension yii2 upload

26/01 2016

0.0.1

0.0.1.0

Extension to upload and store files

  Sources   Download

MIT

The Requires

 

by Ivan Pushkin
by Avatar Vadym Semeniuk

file extension yii2 upload

19/02 2015

dev-testing

dev-testing

Extension to upload and store files

  Sources   Download

MIT

The Requires

 

by Ivan Pushkin

file extension yii2 upload