2017 © Pedro Peláez
 

yii2-extension yii2-easy-thumbnail-image-helper

Yii2 helper for creating and caching thumbnails on real time

image

porcelanosa/yii2-easy-thumbnail-image-helper

Yii2 helper for creating and caching thumbnails on real time

  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 13 Forks
  • 0 Open issues
  • 3 Versions
  • 0 % Grown

The README.md

Easy Thumbnail Image Helper for Yii2

Yii2 helper for creating and caching thumbnails on real time., (*1)

Installation

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

  • Either run
php composer.phar require "porcelanosa/yii2-easy-thumbnail-image-helper" "*"

or add, (*3)

"porcelanosa/yii2-easy-thumbnail-image-helper" : "*"

to the require section of your application's composer.json file., (*4)

  • Add a new component in components section of your application's configuration file (optional), for example:
'components' => [
    'thumbnail' => [
        'class' => 'himiklab\thumbnail\EasyThumbnail',
        'cacheAlias' => 'assets/gallery_thumbnails',
    ],
],

and in bootstrap section, for example:, (*5)

'bootstrap' => ['log', 'thumbnail'],

It is necessary if you want to set global helper's settings for the application., (*6)

Usage

For example:, (*7)

use porcelanosa\thumbnail\EasyThumbnailImage;

echo EasyThumbnailImage::thumbnailImg(
    $model->pictureFile,
    50,
    50,
    EasyThumbnailImage::THUMBNAIL_OUTBOUND,
    ['alt' => $model->pictureName]
);

For other functions please see the source code., (*8)

If you want to handle errors that appear while converting to thumbnail by yourself, please make your own class and inherit it from EasyThumbnailImage. In your class replace only protected method errorHandler. For example, (*9)

class ThumbHelper extends \porcelanosa\thumbnail\EasyThumbnailImage
{

    protected static function errorHandler($error, $filename)
    {
        if ($error instanceof \porcelanosa\thumbnail\FileNotFoundException) {
            return \yii\helpers\Html::img('@web/images/notfound.png');
        } else {
            $filename = basename($filename);
            return \yii\helpers\Html::a($filename,"@web/files/$filename");
        }
    }
} 

The Versions

11/07 2016

dev-master

9999999-dev

Yii2 helper for creating and caching thumbnails on real time

  Sources   Download

MIT

The Requires

 

yii2 helper image thumbnail

13/11 2014

1.0.1

1.0.1.0

Yii2 helper for creating and caching thumbnails on real time

  Sources   Download

MIT

The Requires

 

yii2 helper image thumbnail

29/09 2014

1.0.0

1.0.0.0

Yii2 helper for creating and caching thumbnails on real time

  Sources   Download

MIT

The Requires

 

yii2 helper image thumbnail