Skip to content

Latest commit

 

History

History
32 lines (26 loc) · 941 Bytes

events.md

File metadata and controls

32 lines (26 loc) · 941 Bytes

Handle files after upload

Every file could be processed with global ckeditorRoxyFileman.fileUploaded event, i.e. for create thumbnails for images.

Example

Add event and handler to app config, i.e. backend\config\main.php

'modules' => [],
'on ckeditorRoxyFileman.fileUploaded' => [
    'backend\helpers\ThumbnailHelper', 'createThumbnail'
],

Thumbnail helper with your favourite graphics library, i.e. yii2-imagine

<?php
namespace backend\helpers;

// use Imagine\Image\Box; 
// use Imagine\Image;
// etc

class ThumbnailHelper {
    public static function createThumbnail($event) {
        \Yii::info($event->fileName); // $event->fileName contains filesystem full path to file 
        // Some thumbnail operations, i.e.
        // Image::getImagine()->open($event->fileName)->thumbnail(new Box(600, 600))->save($event->fileName, ['quality' => 100]);
    }
}