2017 © Pedro Peláez
 

yii2-extension yii2-gallery-manager

Extension for yii, that allows to manage image galleries

image

dlds/yii2-gallery-manager

Extension for yii, that allows to manage image galleries

  • Tuesday, December 19, 2017
  • by dlds
  • Repository
  • 2 Watchers
  • 1 Stars
  • 2,135 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 49 Forks
  • 2 Open issues
  • 22 Versions
  • 5 % Grown

The README.md

Gallery Manager usage instructions

Yii2 port of https://github.com/dlds/yii-gallery-manager, (*1)

(frontend part mostly without changes, but backend was rewritten almost completely), (*2)

warning: preview version, (*3)

Features

  1. AJAX image upload
  2. Optional name and description for each image
  3. Possibility to arrange images in gallery
  4. Ability to generate few versions for each image with different configurations
  5. Drag & Drop

Decencies

  1. Yii2
  2. Twitter bootstrap assets (version 3)
  3. Imagine library
  4. JQuery UI (included with Yii)

Installation:

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

Either run, (*5)

php composer.phar require --prefer-dist dlds/yii2-gallery-manager "*@dev", (*6)

or add, (*7)

"dlds/yii2-gallery-manager": "*@dev", (*8)

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

Usage

Add migration to create table for images:, (*10)

class m150318_154933_gallery_ext
    extends dlds\galleryManager\migrations\m140930_003227_gallery_manager
{

}

Add GalleryBehavior to your model, and configure it, create folder for uploaded files., (*11)

public function behaviors()
{
    return [
         'galleryBehavior' => [
             'class' => GalleryBehavior::className(),
             'type' => 'product',
             'extension' => 'jpg',
             'directory' => Yii::getAlias('@contentRoot') . '/images/product/gallery',
             'url' => Yii::getAlias('@web') . '/images/product/gallery',
             'versions' => [
                 'small' => function ($img) {
                     /** @var ImageInterface $img */
                     return $img
                         ->copy()
                         ->thumbnail(new Box(200, 200));
                 },
                 'medium' => function ($img) {
                     /** @var ImageInterface $img */
                     $dstSize = $img->getSize();
                     $maxWidth = 800;
                     if ($dstSize->getWidth() > $maxWidth) {
                         $dstSize = $dstSize->widen($maxWidth);
                     }
                     return $img
                         ->copy()
                         ->resize($dstSize);
                 },
             ]
         ]
    ];
}

Add GalleryManagerAction in controller somewhere in your application. Also on this step you can add some security checks for this action., (*12)

public function actions()
{
    return [
       'galleryApi' => [
           'class' => GalleryManagerAction::className(),
           // mappings between type names and model classes (should be the same as in behaviour)
           'types => [
               'product' => Product::className()
           ]
       ],
    ];
}

Add ImageAttachmentWidget somewhere in you application, for example in editing from., (*13)

if ($model->isNewRecord) {
    echo 'Can not upload images for new record';
} else {
    echo GalleryManager::widget(
        [
            'model' => $model,
            'behaviorName' => 'galleryBehavior',
            'apiRoute' => 'product/galleryApi'
        ]
    );
}

Done!, (*14)

Now, you can use uploaded images from gallery like following:, (*15)

foreach($model->getBehavior('galleryBehavior')->getImages() as $image) {
    echo Html::img($image->getUrl('medium'));
}

The Versions

19/12 2017

dev-master

9999999-dev

Extension for yii, that allows to manage image galleries

  Sources   Download

MIT

The Requires

 

by Jiri Svoboda
by Bogdan Savluk

extension yii2 gallery image

19/12 2017

2.1.3

2.1.3.0

Extension for yii, that allows to manage image galleries

  Sources   Download

MIT

The Requires

 

by Jiri Svoboda
by Bogdan Savluk

extension yii2 gallery image

10/01 2017

2.1.2

2.1.2.0

Extension for yii, that allows to manage image galleries

  Sources   Download

MIT

The Requires

 

by Jiri Svoboda
by Bogdan Savluk

extension yii2 gallery image

13/12 2016

2.1.1

2.1.1.0

Extension for yii, that allows to manage image galleries

  Sources   Download

MIT

The Requires

 

by Jiri Svoboda
by Bogdan Savluk

extension yii2 gallery image

05/11 2016

2.1.0

2.1.0.0

Extension for yii, that allows to manage image galleries

  Sources   Download

MIT

The Requires

 

by Jiri Svoboda
by Bogdan Savluk

extension yii2 gallery image

17/10 2016

2.0.0

2.0.0.0

Extension for yii, that allows to manage image galleries

  Sources   Download

MIT

The Requires

 

by Jiri Svoboda
by Bogdan Savluk

extension yii2 gallery image

21/06 2016

1.2.10

1.2.10.0

Extension for yii, that allows to manage image galleries

  Sources   Download

MIT

The Requires

 

by Jiri Svoboda
by Bogdan Savluk

extension yii2 gallery image

13/06 2016

1.2.9

1.2.9.0

Extension for yii, that allows to manage image galleries

  Sources   Download

MIT

The Requires

 

by Jiri Svoboda
by Bogdan Savluk

extension yii2 gallery image

13/06 2016

1.2.8

1.2.8.0

Extension for yii, that allows to manage image galleries

  Sources   Download

MIT

The Requires

 

by Jiri Svoboda
by Bogdan Savluk

extension yii2 gallery image

13/06 2016

1.2.7

1.2.7.0

Extension for yii, that allows to manage image galleries

  Sources   Download

MIT

The Requires

 

by Jiri Svoboda
by Bogdan Savluk

extension yii2 gallery image

19/04 2016

1.2.6

1.2.6.0

Extension for yii, that allows to manage image galleries

  Sources   Download

MIT

The Requires

 

by Jiri Svoboda
by Bogdan Savluk

extension yii2 gallery image

01/04 2016

1.2.5

1.2.5.0

Extension for yii, that allows to manage image galleries

  Sources   Download

MIT

The Requires

 

by Jiri Svoboda
by Bogdan Savluk

extension yii2 gallery image

10/01 2016

1.2.4

1.2.4.0

Extension for yii, that allows to manage image galleries

  Sources   Download

MIT

The Requires

 

by Jiri Svoboda
by Bogdan Savluk

extension yii2 gallery image

04/06 2015

1.2.3

1.2.3.0

Extension for yii, that allows to manage image galleries

  Sources   Download

MIT

The Requires

 

by Jiri Svoboda
by Bogdan Savluk

extension yii2 gallery image

04/06 2015

1.2.2

1.2.2.0

Extension for yii, that allows to manage image galleries

  Sources   Download

MIT

The Requires

 

by Jiri Svoboda
by Bogdan Savluk

extension yii2 gallery image

04/05 2015

1.2.1

1.2.1.0

Extension for yii, that allows to manage image galleries

  Sources   Download

MIT

The Requires

 

by Jiri Svoboda
by Bogdan Savluk

extension yii2 gallery image

03/05 2015

1.2

1.2.0.0

Extension for yii, that allows to manage image galleries

  Sources   Download

MIT

The Requires

 

by Jiri Svoboda
by Bogdan Savluk

extension yii2 gallery image

02/04 2015

1.1

1.1.0.0

Extension for yii, that allows to manage image galleries

  Sources   Download

MIT

The Requires

 

by Jiri Svoboda
by Bogdan Savluk

extension yii2 gallery image

02/04 2015

1.0

1.0.0.0

Extension for yii, that allows to manage image galleries

  Sources   Download

MIT

The Requires

 

by Jiri Svoboda
by Bogdan Savluk

extension yii2 gallery image

01/04 2015

0.3

0.3.0.0

Extension for yii, that allows to manage image galleries

  Sources   Download

MIT

The Requires

 

by Jiri Svoboda
by Bogdan Savluk

extension yii2 gallery image

01/04 2015

0.2

0.2.0.0

Extension for yii, that allows to manage image galleries

  Sources   Download

MIT

The Requires

 

by Jiri Svoboda
by Bogdan Savluk

extension yii2 gallery image

31/03 2015

0.1

0.1.0.0

Extension for yii, that allows to manage image galleries

  Sources   Download

MIT

The Requires

 

by Jiri Svoboda
by Bogdan Savluk

extension yii2 gallery image