imagesgallerymanager Allows to manage image gallery

  1. Requirements
  2. Usage
  3. Using GalleryBehavior
  4. Changing image versions for gallery associated with behavior
  5. Changelog
  6. Resources

This widget allows to add gallery management with following features:

  • Multiple file upload in modern browser
  • Optional editing image name and description
  • Arrange images in gallery
  • Multiply images actions - edit, removal
  • Behavior to add gallery to any model

Gallery manager screenshots:

GalleryManager images list

Few more screenshots: drag & drop upload, editing image information, upload progress,

Requirements

  • Tested with Yii 1.1.13, but should work with previous versions too
  • Twitter bootstrap css(widget is made using some classes from it)
  • Image component, from extensions repository or better my fork of it

Usage

  1. Checkout source code to your project, for example to ext.galleryManager.
  2. Install and configure image component(https://bitbucket.org/z_bodya/yii-image).
  3. Add tables for gallery into database (there is sql scheme and migration samples in migrations folder in extension)
  4. Import gallery models to project, by adding "ext.galleryManager.models.*" to import in config/main.php
  5. Add GalleryController to application or module controllerMap.
  6. Configure and save gallery model
  7. Render widget for gallery

Example:

// configure and save gallery model
$gallery = new Gallery();
$gallery->name = true;
$gallery->description = true;
$gallery->versions = array(
    'small' => array(
        'resize' => array(200, null),
    ),
    'medium' => array(
        'resize' => array(800, null),
    )
);
$gallery->save();

// render widget in view
$this->widget('GalleryManager', array(
    'gallery' => $gallery,
    'controllerRoute' => '/admin/gallery', //route to gallery controller
));

Using GalleryBehavior

Using gallery behavior is possible to add gallery to any model in application.

To use GalleryBehavior:

Add it to your model:

Example:

public function behaviors()
{
    return array(
        'galleryBehavior' => array(
            'class' => 'GalleryBehavior',
            'idAttribute' => 'gallery_id',
            'versions' => array(
                'small' => array(
                    'centeredpreview' => array(98, 98),
                ),
                'medium' => array(
                    'resize' => array(800, null),
                )
            ),
            'name' => true,
            'description' => true,
        )
    );
}
Add gallery widget to your view:

Example:

<h2>Product galley</h2>
<?php
if ($model->galleryBehavior->getGallery() === null) {
    echo '<p>Before add photos to product gallery, you need to save product</p>';
} else {
    $this->widget('GalleryManager', array(
        'gallery' => $model->galleryBehavior->getGallery(),
    ));
}
?>

Changing image versions for gallery associated with behavior

  1. Update your model with new versions configuration
  2. Run following code(best place for it - in migration):
$models = Model::model()->findAll();
foreach($models as $model) $model->galleryBehavior->changeConfig();

Note: to run in migration you should define 'webroot' path alias.

Changelog

  • September 2, 2013 - Italian translation, some refactoring
  • May 14, 2013 - German translation
  • March 1, 2013 - refactoring, styles upgrade
  • February 26, 2013 - display upload progress
  • February 20, 2013 - added support for drag & drop images upload
  • January 4, 2013 - fixed XSS possibility in html-templates on client side. made some optimisations
  • November 18, 2012 - Added CSRF protection support.
  • Octover 23, 2012 - Fixed mistake in db schema that can cause upload errors on some mysql configurations.
  • August 7, 2012 - Fixed bug with photo select.
  • August 2, 2012 - Added ability use few gallery manager widgets on same page. Moved styles and scripts from view to separate files, added minified script versions.
  • July 29, 2012 - Fixed bug in behavior when tring to insert new record.
  • July 24, 2012 - Begin using jquery.iframe.transport to make ajax file upload in older browsers. Finish work on GalleryBehavior. Remove form tags from widget to make it possible to add it into anouther form tag.
  • July 13, 2012 - Fixed bug(reported by DrMabuse on bitbuket). Bug was in saving order of recently uploaded images.

    Resources

  • Extension page on Bitbucket
  • Forum discussion
  • Example application
28 0
62 followers
10 109 downloads
Yii Version: 1.1
License: BSD-2-Clause
Category: User Interface
Developed by: Bogdan Savluk
Created on: Jul 8, 2012
Last updated: 9 years ago

Downloads

show all

Related Extensions