yii2-filemanager
yii2-filemanager copied to clipboard
Multiple groups of thumbnail patterns
I don't want that every image that I upload creates all of those same thumbnail variants that are defined in configuration, I would like to see two-level thumbnail configuration options. For example, when user uploads his new avatar, I want it to create 3 thumbnails 50x50, 100x100 and 200x200, but when user uploads new article image, I want it to create 2 thumbnails, 150x50 and 300x100 - I don't want three more thumbnails for article images that will not be ever used.
To achieve that, configuration could be grouped:
'modules' => [
'filemanager' => [
'class' => 'pendalf89\filemanager\Module',
// Upload routes
'routes' => [
// Base absolute path to web directory
'baseUrl' => '',
// Base web directory url
'basePath' => '@frontend/web',
// Path for uploaded files in web directory
'uploadPath' => 'uploads',
],
'default-thumbs' => 'default',
// Thumbnails info
'thumbs' => [
'default' => [
'small' => [
'name' => 'Мелкий',
'size' => [100, 100],
],
'medium' => [
'name' => 'Средний',
'size' => [300, 200],
],
'large' => [
'name' => 'Большой',
'size' => [500, 400],
],
],
'user-avatar' => [
'small' => [
'name' => 'Small',
'size' => [50, 50],
],
'medium' => [
'name' => 'Medium',
'size' => [100, 100],
],
'large' => [
'name' => 'Large',
'size' => [200, 200]
]
],
'article-image' => [
'intro' => [
'name' => 'Intro image',
'size' => [150, 50],
],
'full' => [
'name' => 'Full image',
'size' => [300, 100]
]
]
]
]
]
To provide backwards compatibility with current version, checking of thumbs could be done to see if second level of first array element contains size key, if so, thumbs array is parsed in "no-groups" format, otherwise, it is parsed in "groups" format.
Thumbnail group should be provided as GET attribute during file manager module call through either URL or widget configuration.
In addition, for more flexibility and backwards compatibility for widget configurations without specific thumbnail group provided, default-thumbs attribute provides default thumbs group.