PHPackages                             tigrov/yii2-photo-widget - 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. [File &amp; Storage](/categories/file-storage)
4. /
5. tigrov/yii2-photo-widget

ActiveYii2-extension[File &amp; Storage](/categories/file-storage)

tigrov/yii2-photo-widget
========================

Upload photo widget for Yii2

1.1.0(6y ago)014MITPHP

Since Jul 31Pushed 6y ago1 watchersCompare

[ Source](https://github.com/Tigrov/yii2-photo-widget)[ Packagist](https://packagist.org/packages/tigrov/yii2-photo-widget)[ RSS](/packages/tigrov-yii2-photo-widget/feed)WikiDiscussions master Synced 2mo ago

READMEChangelogDependencies (3)Versions (3)Used By (0)

yii2-photo-widget
=================

[](#yii2-photo-widget)

Upload photo widget for Yii2.

[![drawing](photo-widget.png)](photo-widget.png)

[![Latest Stable Version](https://camo.githubusercontent.com/2dfc7e4059f6cfc1884568d5e923eb015aac003fcfb661c752c648e762eaa990/68747470733a2f2f706f7365722e707567782e6f72672f546967726f762f796969322d70686f746f2d7769646765742f762f737461626c65)](https://packagist.org/packages/Tigrov/yii2-photo-widget)

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

[](#installation)

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

Either run

```
php composer.phar require --prefer-dist tigrov/yii2-photo-widget

```

or add

```
"tigrov/yii2-photo-widget": "~1.0"

```

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

Usage
-----

[](#usage)

It is better to use the extension with [yii2-upload-behavior](https://github.com/Tigrov/yii2-upload-behavior)

Once the extension is installed, you can use it as follow:

Create a model with a photo attribute

```
class Model extends \yii\db\ActiveRecord
{
    /**
     * @inheritdoc
     */
    public function behaviors()
    {
        return [
            'upload' => [
                 'class' => '\tigrov\uploadBehavior\UploadBehavior',
                 'path' => '@runtime/upload',
                 'attributes' => ['photo'],
                 // 'saveCallback' => ['\tigrov\photoWidget\PhotoWidgetHelper', 'crop'],
                 // or if you need to crop and resize
                 'saveCallback' => function ($model, $attribute, $file, $filename) {
                     $width = 200;
                     $height = 200;
                     \tigrov\photoWidget\PhotoWidgetHelper::crop($model, $attribute, $file, $filename, $width, $height);
                 }
            ],
        ];
    }

    /**
     * @inheritdoc
     */
    public function rules()
    {
        return [
            [['photo'], 'file', 'skipOnEmpty' => false, 'extensions' => 'png,jpg,jpeg'],
        ];
    }
}
```

Create an action in a controller

```
class FormController extends \yii\web\Controller
{
    public function actionUpload()
    {
        $model = new Model();
        if ($model->load(\Yii::$app->request->post()) && $model->save()) {
            \Yii::$app->session->setFlash('success', 'Model is saved.');
            return $this->refresh();
        }

        return $this->render('form', [
            'model' => $model,
        ]);
    }
}
```

Create a form with the file attribute

```

```

After submitting the photo it will be saved to specified `path`.

License
-------

[](#license)

[MIT](LICENSE)

###  Health Score

26

—

LowBetter than 43% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity6

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity60

Established project with proven stability

 Bus Factor1

Top contributor holds 100% 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 ~0 days

Total

2

Last Release

2477d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/77d285672dec831b7ce5746ab8bb1dd20fffe81fb9d11c232534686706de9697?d=identicon)[Tigros](/maintainers/Tigros)

---

Top Contributors

[![Tigrov](https://avatars.githubusercontent.com/u/8563175?v=4)](https://github.com/Tigrov "Tigrov (12 commits)")

---

Tags

uploadyii2extensionwidgetphoto

### Embed Badge

![Health badge](/badges/tigrov-yii2-photo-widget/health.svg)

```
[![Health](https://phpackages.com/badges/tigrov-yii2-photo-widget/health.svg)](https://phpackages.com/packages/tigrov-yii2-photo-widget)
```

###  Alternatives

[kartik-v/yii2-widget-fileinput

An enhanced FileInput widget for Bootstrap 3.x, 4.x &amp; 5.x with file preview, multiple selection, and more features (sub repo split from yii2-widgets)

2286.8M95](/packages/kartik-v-yii2-widget-fileinput)[noam148/yii2-image-manager

A Yii2 module/widget for upload and cropping images

12914.8k](/packages/noam148-yii2-image-manager)[budyaga/yii2-cropper

Yii-Framework widget for uploading and cropping images

4368.5k4](/packages/budyaga-yii2-cropper)[sjaakp/yii2-illustrated-behavior

ActiveRecord Behavior with associated Widget for Yii2.

423.1k](/packages/sjaakp-yii2-illustrated-behavior)[liyunfang/yii2-upload-behavior

Upload behavior for Yii 2

161.7k](/packages/liyunfang-yii2-upload-behavior)

PHPackages © 2026

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