Yii 1.1: galleria

Extension to support Galleria JavaScript image gallery.

Github repository: Yii-galleria

Based on: EGalleria

28.03.13 updated

update galleria to 1.3.0, minor fixes in widget

What's new

  • Upgrade Galleria to version 1.2.8 2012-08-09
  • Support Galleria plugins, history plugin enabled by default (but others not tested)
  • Support Galleria themes
  • Support min.js or not min .js if Yii DEBUG defined, all JS, CSS in one assets folder
  • Separate thumbnails and images as option
  • Added imagePrefix (behavior), imagePrefixSeparator
  • Added srcPrefix and srcPrefixThumb (example use normal image path and thimbnail image path)


Tested with Yii 1.1.11, but should work with previous versions too


Extract zip archive to ./webapp/protected/extension/galleria

Add import of galleria extension in your config/main.php file:


Using galleria Behavior

Add to image model:

public function behaviors()
        return array(
            'galleria' => array(
                'class' => 'application.extensions.galleria.GalleriaBehavior',
                'image' => 'file_name', //required, will be image name of src
                'imagePrefix' => 'id',//optional, not required
                'description' => 'description',//optional, not required
                'title' => 'name',//optional, not required


$photos = new CActiveDataProvider('GalleryPhoto');
$this->widget('Galleria', array(
    'dataProvider' => $photos,
    'imagePrefixSeparator' => '-',//if set 'imagePrefix' => '' in behaviors; separate - imagePrefix{Separator}image
    'srcPrefix' => '/uploads/gallery/',
    'srcPrefixThumb' => '/uploads/gallery/thumb/',
    #'themeName' => 'folio',//classic by default
    #'plugins' => array('history', 'flickr', 'picasa'),//history by default
    'options' => array(//galleria options
        'transition' => 'fade',
        #'debug' => true,

Binding in widget

$photos = new CActiveDataProvider('GalleryPhoto');
$this->widget('Galleria', array(
    'dataProvider' => $photos,
    'dataProvider' => $data,
    'binding' => array(
        'image' => 'file_name',

Only widget, without Dataprovider and behaviour etc

<?php $this->beginWidget('Galleria');?>
    <img src="/uploads/gallery/1.jpg" alt="Description of image" title="Title of image" />
    <img src="/uploads/gallery/2.jpg" />
    <img src="/uploads/gallery/3.jpg" />
    <img src="/uploads/gallery/4.jpg" />
<?php $this->endWidget();?>


Total 9 comments

#19820 report it
jorge7712051 at 2016/03/31 12:14pm

include(Galleryphoto.php): failed to open stream: No such file or directory why?

#16158 report it
ArturoGP at 2014/01/23 01:05pm
i need redifine the path folder

'srcPrefix' => '/uploads/gallery/', 'srcPrefixThumb' => '/uploads/gallery/thumb/',

what level folder /uploads/gallery/ ????????

#16157 report it
ArturoGP at 2014/01/23 12:08pm
redefine the path srcPrefix and srcPrefixThumb

as I change the path to a folder where I have my images, thanks

#12580 report it
germanliu at 2013/03/29 12:56pm

Hi Fad, thanks!

I was able to advance a lot. I added this to my controller:

$criteria=new CDbCriteria;
$criteria->compare('cyaId', $id);
$photos = new CActiveDataProvider('yachtCYA', array(

And my behavior in my model looks like:

public function behaviors()
        return array(
            'galleria' => array(
                'class' => 'application.extensions.galleria.GalleriaBehavior',
                'image' => 'pic1URL'

With this, it brings me pic1URL of the correct ID, what should I add/modify to bring me pic2URL, pic3URL and pic4URL (this are columns of the same table)? I tried with an array but didn't work. Thank you very much Regards, German

#12565 report it
fad at 2013/03/29 02:48am

Use CActiveRecord or DAO

#12560 report it
germanliu at 2013/03/28 05:11pm

First of all thanks for this extension. Looks great!

I have the following doubts to implement it:

I need it to display pictures from the same record, implemented as is shows one picture from each record. For example, I have a database table with houses and I want to display pictures from ONE house. I have each picture URL saved in a different column of the house table... is this possible? If yes, how should I approach this?

Thanks in advance!!

#12546 report it
fad at 2013/03/28 02:17am
image id to the URL

@bit0123, turn off history plugin (enabled by default)

#12114 report it
bit0123 at 2013/02/27 03:36pm
How to remove image id from URL

Thanks for this easy to use galleria extension.

One problem of this extension is: it shows the image id to the URL. Is there any way to solve this problem?

Any suggestion will be highly appreciable.

Thanks in advance...

#9464 report it
sirin k at 2012/08/13 02:19pm
Nice 1

Nice one.thanks for the post.

Leave a comment

Please to leave your comment.

Create extension