PHPackages                             agapofff/yii2-gallery - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Image &amp; Media](/categories/media)
4. /
5. agapofff/yii2-gallery

ActiveYii2-extension[Image &amp; Media](/categories/media)

agapofff/yii2-gallery
=====================

Allows to attach images to any model

v1.0.3(4y ago)08Apache-2.0PHPPHP &gt;=5.4.0

Since Mar 30Pushed 3y agoCompare

[ Source](https://github.com/agapofff/yii2-gallery)[ Packagist](https://packagist.org/packages/agapofff/yii2-gallery)[ Docs](https://github.com/agapofff/yii2-gallery)[ RSS](/packages/agapofff-yii2-gallery/feed)WikiDiscussions master Synced 4d ago

READMEChangelog (3)Dependencies (5)Versions (4)Used By (0)

Yii2-gallery
============

[](#yii2-gallery)

This extension allows you to:

- attach images to any model
- fill titles and alt attributes of those images
- change images order by simple drag-n-drop
- wrap every image to it's own link

Installation
------------

[](#installation)

### With [composer](http://getcomposer.org/download/)

[](#with-composer)

Run

```
composer require agapofff/yii2-gallery "*"

```

or add

```
"agapofff/yii2-gallery": "*",

```

to composer.json and run

```
php composer update

```

Use migration

```
php yii migrate/up --migrationPath=@vendor/agapofff/yii2-gallery/src/migrations

```

Settings
--------

[](#settings)

Add to config file

```
'modules' => [
    //...
    'gallery' => [
        'class' => 'agapofff\gallery\Module',
        'imagesStorePath' => dirname(dirname(__DIR__)).'/frontend/web/images/store', //path to origin images
        'imagesCachePath' => dirname(dirname(__DIR__)).'/frontend/web/images/cache', //path to resized copies
        'graphicsLibrary' => 'GD', // or Imagick
        'placeHolderPath' => '@webroot/images/placeHolder.png', // path to placeholder image
        'adminRoles' => ['admin', 'manager'], // use '@' to allow authorized users attach images on frontend
    ],
    //...
]
```

Add behaviour to the model to which you want to attach images

```
function behaviors()
{
    return [
        'images' => [
            'class' => 'agapofff\gallery\behaviors\AttachImages',
            'mode' => 'gallery',        // or 'single' - one image
            'quality' => 60,            // percentage of image quality compression
            'galleryId' => 'gallery'    // use this unique options for resolving conflicts the same class names
        ],
    ];
}
```

Add `enctype="multipart/form-data"` to you model form

```
$form = ActiveForm::begin([
    'options' => [
        'enctype' => 'multipart/form-data'
    ]
]);
```

Add the widget for uploading images in your form

```

```

Getting attached images params

```
$image = $model->getImage();    // get attached image in single mode
$images = $model->getImages();  // get all attached images in gallery mode

$image->getUrl();               // url to full image
$image->getUrl('300x');         // url to proportionally resized image by width
$image->getUrl('x300');         // url to proportionally resized image by height
$image->getUrl('200x300');      // url to resized and cropped (centered) image by width and height

$image->getPath();              // filepath to original image
$image->getPath('50x50');       // filepath to sized image

$image->getContent();           // content of original image file
$image->getContent('100x');     // content of sized image file

$image->getSizes();             // array of generated image sizes: ['width' => 1000, 'height' => 500]
$image->getSizesWhen('100x');   // array of generated image sizes with condition

$image->alt;                    // image alt attribute
$image->title;                  // image title
$image->description;            // image description
$image->gallery_id;             // unique gallery name (if set)
$image->url;                    // link for image
$image->newPage;                // open link in new page
$image->isMain;                 // is this image is main in gallery
```

based on [dvizh/yii2-gallery](https://github.com/dvizh/yii2-gallery)

###  Health Score

21

—

LowBetter than 19% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity4

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity46

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 56% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~7 days

Total

3

Last Release

1493d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/c383d4ec42c7f7ba0fe7b9c05ba7a3b604c5f0ce70c0f10ff9b91b467d8ca3d0?d=identicon)[agapofff](/maintainers/agapofff)

---

Top Contributors

[![agapofff](https://avatars.githubusercontent.com/u/56738935?v=4)](https://github.com/agapofff "agapofff (14 commits)")[![pistol88](https://avatars.githubusercontent.com/u/8104605?v=4)](https://github.com/pistol88 "pistol88 (9 commits)")[![PROloggg](https://avatars.githubusercontent.com/u/25814457?v=4)](https://github.com/PROloggg "PROloggg (2 commits)")

---

Tags

imagesyii2yii2-imagesagapofff

### Embed Badge

![Health badge](/badges/agapofff-yii2-gallery/health.svg)

```
[![Health](https://phpackages.com/badges/agapofff-yii2-gallery/health.svg)](https://phpackages.com/packages/agapofff-yii2-gallery)
```

###  Alternatives

[costa-rico/yii2-images

yii2 images module for storing images

16461.6k4](/packages/costa-rico-yii2-images)[skeeks/cms

SkeekS CMS — control panel and tools based on php framework Yii2

13825.6k47](/packages/skeeks-cms)[bilginnet/yii2-cropper

Yii2 Bootstrap Cropper Input Widget

2232.1k](/packages/bilginnet-yii2-cropper)[maxmirazh33/yii2-uploadable-cropable-image

Yii2 extension for upload and crop images

1020.8k](/packages/maxmirazh33-yii2-uploadable-cropable-image)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
