PHP code example of assayer-pro / yii2-easy-thumbnail-image-helper
1. Go to this page and download the library: Download assayer-pro/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/ */
assayer-pro / yii2-easy-thumbnail-image-helper example snippets
'components' => [
'thumbnail' => [
'class' => 'assayerpro\thumbnail\EasyThumbnailImage',
'cacheAlias' => 'assets/gallery_thumbnails',
'quality' => 90,
],
],
use assayerpro\thumbnail\EasyThumbnailImage;
echo Yii::$app->thumbnail->thumbnailImg(
$model->pictureFile,
50,
50,
EasyThumbnailImage::THUMBNAIL_OUTBOUND,
['alt' => $model->pictureName]
);
use assayerpro\thumbnail\EasyThumbnailImage;
echo Yii::$app->thumbnail->thumbnailImg(
'http://...',
50,
50,
EasyThumbnailImage::THUMBNAIL_OUTBOUND,
);
use assayerpro\thumbnail\EasyThumbnailImage;
echo Yii::$app->thumbnail->thumbnailImg(
$model->pictureFile,
50,
null
);
class ThumbHelper extends \assayerpro\thumbnail\EasyThumbnailImage
{
protected static function errorHandler($error, $filename)
{
if ($error instanceof \assayerpro\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