PHP code example of porcelanosa / yii2-easy-thumbnail-image-helper
1. Go to this page and download the library: Download porcelanosa/yii2-easy-thumbnail-image-helper library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
porcelanosa / yii2-easy-thumbnail-image-helper example snippets
'components' => [
'thumbnail' => [
'class' => 'himiklab\thumbnail\EasyThumbnail',
'cacheAlias' => 'assets/gallery_thumbnails',
],
],
'bootstrap' => ['log', 'thumbnail'],
use porcelanosa\thumbnail\EasyThumbnailImage;
echo EasyThumbnailImage::thumbnailImg(
$model->pictureFile,
50,
50,
EasyThumbnailImage::THUMBNAIL_OUTBOUND,
['alt' => $model->pictureName]
);
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");
}
}
}
php composer.phar