Difference between #1 and #2 of
Using Yii Gallery Manager in your Yii 1.x application

Changes

Title unchanged

Using Yii Gallery Manager in your Yii 1.x application

Category unchanged

How-tos

Yii version unchanged

Tags unchanged

gallery manager, Image Gallery

Content changed

Finding good looking, working and not abandoned gallery manager for Yii 1.x application is a tough task. Out of all I found, only [_yii-gallery-manager_](http://www.yiiframework.com/extension/imagesgallerymanager/) extension looked promising. But, after downloading it, it turned out, that there are certain unusual things to do, to include it in your application. So, I decided to write this article to remember all these for future reference. ## Before you start

Here are some initial points, you should go through, to learn, if this extension is for you:
[...]
If you're convinced to use this extension, then continue reading. If resign, you can scroll to the end of this text, where I put some alternatives.

## Preparation stage

To install and use this extension in your application you need:
[...]
Double check, if path/alias (`application.extensions.image` here) are correct and valid. Most operations in _yii-gallery-manager_ extension are made via POST/AJAX and debugging them is a little bit harder. Wrong path/alias to _yii-image_ extension is first source of problems with Gallery Manager not uploading images correctly.

## Adding _yii-gallery-manager_ to your application

I decided to use behavior-based approach, because using behaviors is more flexible.
[...]
),

## Adding behavior and views

Now, your application should be ready to use this extension. All, that is left is to add behavior to your model:
[...]
<?php $photos = $content->galleryBehavior->getGalleryPhotos(); ?>

## Tuning up

### Files, folders and paths
[...]
Resizing images is most popular operation made for auto-generated previews, but `Image` class provides you with a lot of graphical effects and image transformations. You can emboss, sharpen, negate image, flip it and rotate it etc.

If this is only possible, try to set fixed value here and do not change it later. Extension provides you with [a nifty tool for updating all versions (previews) of images later](http://www.yiiframework.com/extension/imagesgallerymanager/#
#hh5) -- you need to call `$model->galleryBehavior->changeConfig();` on each model, which versions / previews are about to change. But, this isn't recommended way, as this will modify many files on-the-fly and can even bloat your server (if you have really big number of galleries there).

Keep in mind, that `versions` array is kept (serialized) in database for each of your gallery. Therefore, you have to call `$model->galleryBehavior->changeConfig();` for each of gallery already stored in database, after changing `versions` settings.
[...]
Without this `assets/galleryManager.css`, images area in your gallery won't be vertically scrollable and you will have no access to other photos, if you upload many images to particular gallery. Remember to remove assets after applying these changes, to actually see them on-line.

## Using migrations

If you're using migrations to update database, then note, that `schema.migration` file found in `migrations` folder in _yii-gallery-manager_ extension folder has some problems, that should be / must be corrected.
[...]
$this->addColumn('contents', 'gallery_id', "integer DEFAULT NULL COMMENT 'Foregin key to Gallery -- gallery for this content' AFTER `content_id`");

## Debugging

You can use modified piece of code from `GalleryController::actionAjaxUpload()` to do pretty nice debugging. Put this code somewhere (in some view?) and execute:
[...]
It helped me discover problems with database (incorrect table names) in first place and it brought me answer, why the heck images are not uploaded? After three hours of searching, I found out, that Yii isn't able to find `CImageComponent`. I wasn't able to discover this earlier, because all upload-related events occurs in post-only, ajax-mode mood, which is quite hard to debug.

## Demo application

There's a nice looking and (nearly) ready to use demo application found at BitBucket (this time repository is cloneable): <https://bitbucket.org/z_bodya/yii-demo-blog>. It contains Gallery Manager and other extensions made by this author.
[...]
Read [this article](Installing Composer to PHP on Windows.txt) if you don't have Composer on your Windows and need to install it.

Note, that demo applications includes gallery's cover image functionality, [requested by some user](http://www.yiiframework.com/extension/imagesgallerymanager/#
#c17786) and [implemented](http://www.yiiframework.com/extension/imagesgallerymanager/##c17787) as a part of [separate branch](https://bitbucket.org/z_bodya/gallerymanager/branch/Ilya). It is not included in `master` branch and since branches at BitBucket are not accessible right now, you can only get this feature by hand-copying changed code. ## Sources and information

Here is a list of pages, you may wish to visit to read more about _yii-gallery-manager_:
[...]
There's also a [forum discussion](http://www.yiiframework.com/forum/index.php/topic/33477-gallery-manager-extension/) on this extension, but last post (unanswered) is over two years old now. So, this forum is pretty useless.

## Some alternatives

If, for any reason, _yii-gallery-manager_ is not an option for you, you can consider these alternatives:

- <https://code.google.com/p/yii-gallery-extension/>
- <https://github.com/Crisu83/yii-imagemanager>
[...]
0 0
1 follower
Viewed: 15 950 times
Version: 1.1
Category: How-tos
Written by: Trejder
Last updated by: Trejder
Created on: Mar 18, 2015
Last updated: 9 years ago
Update Article

Revisions

View all history