2017 © Pedro Peláez
 

yii2-extension yii2-display-image2

Yii2: Auto resize image

image

pavlinter/yii2-display-image2

Yii2: Auto resize image

  • Monday, April 23, 2018
  • by pavlinter
  • Repository
  • 2 Watchers
  • 1 Stars
  • 180 Installations
  • PHP
  • 2 Dependents
  • 0 Suggesters
  • 3 Forks
  • 0 Open issues
  • 21 Versions
  • 6 % Grown

The README.md

Yii2 Display Image2

Installation

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

Either run, (*2)

php composer.phar require --prefer-dist pavlinter/yii2-display-image2 "dev-master"

or add, (*3)

"pavlinter/yii2-display-image2": "dev-master"

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

Configuration

'modules' => [
  'display2'=> [
      'class'=>'pavlinter\display2\Module',
      'appendTimestamp' => true,
      'categories' => [
          'all' => [
              'imagesWebDir' => '@web/display-images/images',
              'imagesDir' => '@webroot/display-images/images',
              'defaultWebDir' => '@web/display-images/default',
              'defaultDir' => '@webroot/display-images/default',
              'mode' => \pavlinter\display2\objects\Image::MODE_OUTBOUND,
          ],
          'items' => [
              'appendTimestamp' => false,
              'generalDefaultDir' => false,
              'imagesWebDir' => '@web/display-images/items',
              'imagesDir' => '@webroot/display-images/items',
              'defaultWebDir' => '@web/display-images/default/items',
              'defaultDir' => '@webroot/display-images/default/items',
              'mode' => \pavlinter\display2\objects\Image::MODE_STATIC,
          ],
      ],
 ],
],
'components' => [
  'display' => [
    'class' => 'pavlinter\display2\components\Display',
    'resizeModes' => [
        'ownResizeMode' => 'pavlinter\display2\objects\ResizeMode',
        'ownResizeModeParams' => [
            'class' => 'pavlinter\display2\objects\ResizeMode',
        ],
        'ownResizeModeFunc' => function ($image, $originalImage) {
            /* @var $this \pavlinter\display2\components\Display */
            /* @var $image \pavlinter\display2\objects\Image */
            /* @var $originalImage \Imagine\Gd\Image */
            return $originalImage->thumbnail(new \Imagine\Image\Box($image->width, $image->height), \pavlinter\display2\objects\Image::MODE_OUTBOUND);
        }
    ],
  ],
],

Crop with url

//get all images from folder
//where 1 is id number from database
$images =  Yii::$app->display->getFileImgs(1, 'items', [
  'width' => 100,
  'height' => 100,
  'mode' => \pavlinter\display2\objects\Image::MODE_OUTBOUND,
  'loadingOptions' => [],
],[
  'dir' => 'mainDir',
  'minImages' => 2,
  'maxImages' => 6,
  'recursive' => false,
]);
//return from /display-images/items/1/mainDir/
[
  1204270244_1.jpg' => [
      'id_row' => 1
      'key' => 0
      'fullPath' => 'basePath..../web/display-images/items/1/1204270244_1.jpg'
      'dirName' => '1204270244_1.jpg'
      'imagesDir' => 'basePath..../web/display-images/items/1/'
      'imagesWebDir' => '/display-images/items/1/'
      'originImage' => '/display-images/items/1/1204270244_1.jpg'
      'image' => '1204270244_1.jpg'
      'display' => '/ru/display2/image/crop?width=100&height=100&mode=outbound&category=items&id_row=1&image=1204270244_1.jpg'
      'displayLoading' => '

\"1204270244_1\"
' ] ] echo Yii::$app->display->createUrl([ 'width' => 120, 'image' => '/subfolders/bg.jpg', 'category' => 'all', 'mode' => \pavlinter\display2\objects\Image::MODE_OUTBOUND, ]); echo Yii::$app->display->showImg([ 'id_row' => 2, 'width' => 100, 'image' => 'd.jpeg', 'category' => 'items', 'mode' => \pavlinter\display2\objects\Image::MODE_STATIC, ]); echo Yii::$app->display->showImg([ 'id_row' => 2, 'width' => 100, 'image' => 'd.jpeg', 'category' => 'items', 'mode' => 'ownResizeMode', ]);

Crop now

echo Yii::$app->display->showCropImage([ //subfolders image
    'width' => 120,
    'image' => '/subfolders/bg.jpg', // or subfolders/bg.jpg
    'category' => 'all',
]);

echo Yii::$app->display->showCropImage([
    'id_row' => 2,
    'width' => 100,
    'image' => 'd.jpeg',
    'category' => 'items',
]);

echo Yii::$app->display->showCropImage([ //new name
    'name' => 'newName',
    'width' => 100,
    'height' => 130,
    'image' => '334.gif',
    'category' => 'all',
]);

echo Yii::$app->display->showCropImage([ //return default Html::img from items category
    'id_row' => 2,
    'width' => 100,
    'image' => 'rddddd',
    'category' => 'items',
]);

The Versions

23/04 2018

dev-master

9999999-dev

Yii2: Auto resize image

  Sources   Download

BSD-3-Clause BSD 3-Clause

The Requires

 

by Pavels Radajevs

yii2 image resize crop display displayimage display-image2 auto crop auto resize

23/04 2018

v2.3.4

2.3.4.0

Yii2: Auto resize image

  Sources   Download

BSD-3-Clause

The Requires

 

by Pavels Radajevs

yii2 image resize crop display displayimage display-image2 auto crop auto resize

18/04 2018

v2.3.2

2.3.2.0

Yii2: Auto resize image

  Sources   Download

BSD-3-Clause

The Requires

 

by Pavels Radajevs

yii2 image resize crop display displayimage display-image2 auto crop auto resize

16/04 2018

v2.3.1

2.3.1.0

Yii2: Auto resize image

  Sources   Download

BSD-3-Clause

The Requires

 

by Pavels Radajevs

yii2 image resize crop display displayimage display-image2 auto crop auto resize

12/02 2018

v2.3.0

2.3.0.0

Yii2: Auto resize image

  Sources   Download

BSD-3-Clause

The Requires

 

by Pavels Radajevs

yii2 image resize crop display displayimage display-image2 auto crop auto resize

22/01 2018

v2.2.0

2.2.0.0

Yii2: Auto resize image

  Sources   Download

BSD 3-Clause

The Requires

 

by Pavels Radajevs

yii2 image resize crop display displayimage display-image2 auto crop auto resize

31/12 2017

v2.1.4

2.1.4.0

Yii2: Auto resize image

  Sources   Download

BSD 3-Clause

The Requires

 

by Pavels Radajevs

yii2 image resize crop display displayimage display-image2 auto crop auto resize

27/12 2017

v2.1.3

2.1.3.0

Yii2: Auto resize image

  Sources   Download

BSD 3-Clause

The Requires

 

by Pavels Radajevs

yii2 image resize crop display displayimage display-image2 auto crop auto resize

27/12 2017

v2.1.2

2.1.2.0

Yii2: Auto resize image

  Sources   Download

BSD 3-Clause

The Requires

 

by Pavels Radajevs

yii2 image resize crop display displayimage display-image2 auto crop auto resize

25/12 2017

v2.1.1

2.1.1.0

Yii2: Auto resize image

  Sources   Download

BSD 3-Clause

The Requires

 

by Pavels Radajevs

yii2 image resize crop display displayimage display-image2 auto crop auto resize

17/11 2017

v2.1.0

2.1.0.0

Yii2: Auto resize image

  Sources   Download

BSD 3-Clause

The Requires

 

by Pavels Radajevs

yii2 image resize crop display displayimage display-image2 auto crop auto resize

05/03 2017

v2.0.0

2.0.0.0

Yii2: Auto resize image

  Sources   Download

BSD 3-Clause

The Requires

 

by Pavels Radajevs

yii2 image resize crop display displayimage display-image2 auto crop auto resize

14/01 2017

0.3.1

0.3.1.0

Yii2: Auto resize image

  Sources   Download

BSD 3-Clause

The Requires

 

by Pavels Radajevs

yii2 image resize crop display displayimage display-image2 auto crop auto resize

07/12 2016

0.3.0

0.3.0.0

Yii2: Auto resize image

  Sources   Download

BSD 3-Clause

The Requires

 

by Pavels Radajevs

yii2 image resize crop display displayimage display-image2 auto crop auto resize

16/11 2016

0.2.0

0.2.0.0

Yii2: Auto resize image

  Sources   Download

BSD 3-Clause

The Requires

 

by Pavels Radajevs

yii2 image resize crop display displayimage display-image2 auto crop auto resize

03/10 2016

0.1.0

0.1.0.0

Yii2: Auto resize image

  Sources   Download

BSD 3-Clause

The Requires

 

by Pavels Radajevs

yii2 image resize crop display displayimage display-image2 auto crop auto resize

01/07 2016

0.0.4

0.0.4.0

Yii2: Auto resize image

  Sources   Download

BSD 3-Clause

The Requires

 

by Pavels Radajevs

yii2 image resize crop display displayimage display-image2 auto crop auto resize

28/12 2015

0.0.3

0.0.3.0

Yii2: Auto resize image

  Sources   Download

BSD 3-Clause

The Requires

 

by Pavels Radajevs

yii2 image resize crop display displayimage display-image2 auto crop auto resize

04/12 2015

0.0.2

0.0.2.0

Yii2: Auto resize image

  Sources   Download

BSD 3-Clause

The Requires

 

by Pavels Radajevs

yii2 image resize crop display displayimage display-image2 auto crop auto resize

02/12 2015

0.0.1

0.0.1.0

Yii2: Auto resize image

  Sources   Download

BSD 3-Clause

The Requires

 

by Pavels Radajevs

yii2 image resize crop display displayimage display-image2 auto crop auto resize

01/12 2015

0.0.0

0.0.0.0

Yii2: Auto resize image

  Sources   Download

BSD 3-Clause

The Requires

 

by Pavels Radajevs

yii2 image resize crop display displayimage display-image2 auto crop auto resize