Gallery Manager extension

This thread is for anouther extension:

Hi, I’m having problems with uploading new image:

There’s no form and only cancel button works. When I click cancel and manually reload page image shows in the gallery as uploaded with empty name and description.

Check what responce comes from server. Probably there will be error description(you can see responce from server in network tab in chrome developer tools)

Sounds a good extension ideea, i’ll give it a try.

Here’s the error log.

PHP warning

call_user_func_array() expects parameter 1 to be a valid callback, class 'Image' does not have a method 'centeredpreview'


136     }


138     public function setImage($path)

139     {

140         //save image in original size

141         Yii::app()->image->load($path)->save($this->galleryDir . '/' . $this->getFileName('') . '.' . $this->galleryExt);

142         //create image preview for gallery manager

143         Yii::app()->image->load($path)->resize(300, null)->save($this->galleryDir . '/_' . $this->getFileName('') . '.' . $this->galleryExt);


145         foreach ($this->gallery->versions as $version => $actions) {

146             $image = Yii::app()->image->load($path);

147             foreach ($actions as $method => $args) {

148                 call_user_func_array(array($image, $method), is_array($args) ? $args : array($args));

149             }

150             $image->save($this->galleryDir . '/' . $this->getFileName($version) . '.' . $this->galleryExt);

151         }

152     }


154     public function delete()

155     {

156         $this->removeFile($this->galleryDir . '/' . $this->getFileName('') . '.' . $this->galleryExt);

157         //create image preview for gallery manager

158         $this->removeFile($this->galleryDir . '/_' . $this->getFileName('') . '.' . $this->galleryExt);


160         foreach ($this->gallery->versions as $version => $actions) {

This happens with original image extension.

With modified one no properties window is shown and I get this:

SyntaxError: JSON.parse: unexpected non-whitespace character after JSON data

var resp = JSON.parse(this.response);

At jquery.galleryManager.js line 144

If you are using original Image extension, you should know that there is no method named "centeredpreview" - it is method added in my fork.

So if you need this method - use proper image extension, or implement your own centeredpreview method in image extension.

I tried your fork and got the following error:

SyntaxError: JSON.parse: unexpected non-whitespace character after JSON data

var resp = JSON.parse(this.response);

At jquery.galleryManager.js line 144

This error happens because server response is not json( as it is required by client script) - it is html text with description of an error that happend on a server.

You should look for error description in server response.

Thanks for your great extension.

Using your cms-app i can successfully access(upload image, update…) the admin gallery controller.

But the problem is in the index page the gallery is not shown.

How can i do this?

I’m using GalleryBehavior.

In Google Chrome I get different error at console:

Uncaught SyntaxError: Unexpected token < jquery.galleryManager.js:144

xhr.onload jquery.galleryManager.js:144

There’s no error in server response, just this (see attached)

Response should be json - the problem is in CWebLogRoute, it appends html code to json, so response it can not be parsed as JSON.

Try to disable CWebLogRoute.

Ok, I disabled it and now all work fine. Thanks!!

Расширение очень понравилось. А возможно ли как-то манипулировать качеством jpeg-сжатия изображений?

Да, для обработки изображений используется расширение yii-image: там есть метод quality для установки качества созранения в процентах.

О. Супер. Помогло:

$gallery->versions = array(

                'small' => array(

                    'resize' => array(200, null),

                    'quality' => array(75),


                'medium' => array(

                    'resize' => array(620, null),

                    'quality' => array(75),



А есть возможность автоматически накладывать водяной знак?

Тут я добавил метод для добавления водяных знаков.


I have bug please help me

When I click button on the right and it not work and I see console bug

<h1>PHP Error [8]</h1>

<p>Use of undefined constant php - assumed ‘php’ (D:\www\demo\protected\modules\imgManager\views\pl\_gallery_form.php:130)</p>

<pre>#0 D:\www\demo\protected\modules\imgManager\views\pl\_gallery_form.php(130): CWebApplication->handleError()

#1 D:\www\yii-1.1.12\framework\web\CBaseController.php(127): require()

#2 D:\www\yii-1.1.12\framework\web\CBaseController.php(96): PlController->renderInternal()

#3 D:\www\yii-1.1.12\framework\web\CController.php(870): PlController->renderFile()

#4 D:\www\demo\protected\modules\imgManager\controllers\PlController.php(363): PlController->renderPartial()

#5 D:\www\yii-1.1.12\framework\web\actions\CInlineAction.php(50): PlController->actionReturnGalForm()

#6 D:\www\yii-1.1.12\framework\web\CController.php(309): CInlineAction->runWithParams()

#7 D:\www\yii-1.1.12\framework\web\filters\CFilterChain.php(134): PlController->runAction()

#8 D:\www\yii-1.1.12\framework\web\filters\CFilter.php(41): CFilterChain->run()

#9 D:\www\yii-1.1.12\framework\web\filters\CFilterChain.php(131): YXssFilter->filter()

#10 D:\www\yii-1.1.12\framework\web\CController.php(292): CFilterChain->run()

#11 D:\www\yii-1.1.12\framework\web\CController.php(266): PlController->runActionWithFilters()

#12 D:\www\yii-1.1.12\framework\web\CWebApplication.php(283): PlController->run()

#13 D:\www\yii-1.1.12\framework\web\CWebApplication.php(142): CWebApplication->runController()

#14 D:\www\yii-1.1.12\framework\base\CApplication.php(162): CWebApplication->processRequest()

#15 D:\www\demo\index.php(13): CWebApplication->run()


This thread, is about another extension imagesgallerymanager, not about that you are using(gallerymanager).

Hi Bogdan,

I’ve been reading and checking all the material you’ve setup (btw, thanks a ton!), including the test-app, which works fine on my local test server. Then I’ve switched to my project, installed the extension and loaded the image and bootstrap components in my main config. Finally, I’ve added the Controller to my controllerMap, such as:

	'controllerMap' => array(



	        'pageTitle'=>'Gallery administration',



I want to use the GalleryBehavior with one of my models (model Structure) so I’ve added this to my model code:

	public function behaviors()


	    return array(

	        'galleryBehavior' => array(

	            'class' => 'application.extensions.galleryManager.GalleryBehavior',

	            'idAttribute' => 'gallery_id',

	            'versions' => array(

	                'small' => array(

	                    'centeredpreview' => array(98, 98),


	                'medium' => array(

	                    'resize' => array(800, null),



	            'name' => true,

	            'description' => true,




And to my model’s view:


if ($model->galleryBehavior->getGallery() === null) {

    echo '<p>Before add photos to product gallery, you need to save product</p>';

} else {

    $this->widget('application.extensions.galleryManager.GalleryManager', array(

        'gallery' => $model->galleryBehavior->getGallery(),




Problem is, when i call my view I get an error, file mixins.less not found, but the gallery panel gets loaded. Clicking to add images lets you choose images, but it calls an obviously wrong action (http://localhost:8088/index.php/ajaxUpload/gallery_id/4) and then it throws a new error while responding

Unable to resolve the request "ajaxUpload/gallery_id".

What am I doing wrong?

Thanks in advance for any hint, document or suggestion you may provide.