PHPackages                             dlds/yii2-imageable - 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. dlds/yii2-imageable

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

dlds/yii2-imageable
===================

Yii2 extension for handling AR images

0.3.1(11y ago)0901BSD-3-ClausePHP

Since Jan 21Pushed 11y ago1 watchersCompare

[ Source](https://github.com/dlds/yii2-imageable)[ Packagist](https://packagist.org/packages/dlds/yii2-imageable)[ RSS](/packages/dlds-yii2-imageable/feed)WikiDiscussions master Synced 1mo ago

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

ImageAttachment
===============

[](#imageattachment)

This extension intended to handle images associated with model.

Extensions provides user friendly widget, for image upload and removal.

[![Yii2 image attachement screenshot](https://camo.githubusercontent.com/c2abf09f4ce0814091826ff0de36740817bf5f11c87fc66b7406076bcf078a15/687474703a2f2f7a78626f6479612e63632e75612f73637275702f39302f6f7963616235626377306777632e706e67)](https://camo.githubusercontent.com/c2abf09f4ce0814091826ff0de36740817bf5f11c87fc66b7406076bcf078a15/687474703a2f2f7a78626f6479612e63632e75612f73637275702f39302f6f7963616235626377306777632e706e67)

Features
--------

[](#features)

1. Asynchronous image upload
2. Ability to generate few image versions with different configurations
3. Drag &amp; Drop

Decencies
---------

[](#decencies)

1. Yii2
2. Twitter bootstrap assets
3. Imagine library

Installation:
-------------

[](#installation)

The preferred way to install this extension is through [composer](https://getcomposer.org/).

Either run

`php composer.phar require --prefer-dist zxbodya/yii2-image-attachment "*@dev"`

or add

`"zxbodya/yii2-image-attachment": "*@dev"`

to the require section of your `composer.json` file.

Usage
-----

[](#usage)

Add ImageAttachmentBehavior to your model, and configure it, create folder for uploaded files.

```
public function behaviors()
{
    return [
        TimestampBehavior::className(),
        'coverBehavior' => [
            'class' => ImageAttachmentBehavior::className(),
            // type name for model
            'type' => 'post',
            // image dimmentions for preview in widget
            'previewHeight' => 200,
            'previewWidth' => 300,
            // extension for images saving
            'extension' => 'jpg',
            // path to location where to save images
            'directory' => Yii::getAlias('@webroot') . '/images/post/cover',
            'url' => Yii::getAlias('@web') . '/images/post/cover',
            // additional image versions
            'versions' => [
                'small' => function ($img) {
                    /** @var ImageInterface $img */
                    return $img
                        ->copy()
                        ->resize($img->getSize()->widen(200));
                },
                'medium' => function ($img) {
                    /** @var ImageInterface $img */
                    $dstSize = $img->getSize();
                    $maxWidth = 800;
                    if ($dstSize->getWidth() > $maxWidth) {
                        $dstSize = $dstSize->widen($maxWidth);
                    }
                    return $img
                        ->copy()
                        ->resize($dstSize);
                },
            ]
        ]
    ];
}
```

Add ImageAttachmentAction in controller somewhere in your application. Also on this step you can add some security checks for this action.

```
public function actions()
{
    return [
        'imgAttachApi' => [
            'class' => ImageAttachmentAction::className(),
            // mappings between type names and model classes (should be the same as in behaviour)
            'types' => [
                'post' => Post::className()
            ]
        ],
    ];
}
```

Add ImageAttachmentWidget somewhere in you application, for example in editing from.

```
echo ImageAttachmentWidget::widget(
    [
        'model' => $model,
        'behaviorName' => 'coverBehavior',
        'apiRoute' => 'test/imgAttachApi',
    ]
)
```

Done! Now, you can use it in other places in app too:

```
if ($model->getBehavior('coverBehavior')->hasImage()) {
    echo Html::img($model->getBehavior('coverBehavior')->getUrl('medium'));
}
```

###  Health Score

26

—

LowBetter than 43% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity10

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity56

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 85.7% 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 ~6 days

Total

4

Last Release

4109d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/23f0d05bb48111bd348c97af007c453b374ba03c36ec4fd114dfd73896bf5958?d=identicon)[dlds](/maintainers/dlds)

---

Top Contributors

[![zxbodya](https://avatars.githubusercontent.com/u/446117?v=4)](https://github.com/zxbodya "zxbodya (24 commits)")[![jirisvoboda](https://avatars.githubusercontent.com/u/10264326?v=4)](https://github.com/jirisvoboda "jirisvoboda (3 commits)")[![svobik7](https://avatars.githubusercontent.com/u/761766?v=4)](https://github.com/svobik7 "svobik7 (1 commits)")

---

Tags

imageyii2extension

### Embed Badge

![Health badge](/badges/dlds-yii2-imageable/health.svg)

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

###  Alternatives

[yurkinx/yii2-image

Yii2 extension for image manipulating using Kohana Image Library.

66412.9k9](/packages/yurkinx-yii2-image)[noam148/yii2-image-resize

A Yii2 component for resizing images (on the fly)

1144.6k7](/packages/noam148-yii2-image-resize)[raoul2000/yii2-jcrop-widget

This extension is a wrapper for the jQuery Image Cropping Plugin (jcrop)

10248.3k2](/packages/raoul2000-yii2-jcrop-widget)[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)
