PHPackages                             panix/mod-images - 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. panix/mod-images

ActivePixelion-module[Image &amp; Media](/categories/media)

panix/mod-images
================

PIXELION CMS module images

1.0.1(3y ago)0241MITPHP

Since Feb 4Pushed 3y ago1 watchersCompare

[ Source](https://github.com/andrtechno/mod-images)[ Packagist](https://packagist.org/packages/panix/mod-images)[ RSS](/packages/panix-mod-images/feed)WikiDiscussions master Synced 2w ago

READMEChangelog (2)Dependencies (6)Versions (3)Used By (0)

mod-images
==========

[](#mod-images)

Guys, we definetly need to do something with this repo. I see several ways:

- to write tests
- to find active contributers
- to find some alternative repo

What do you prefer? please let me know. Yii2-images is yii2 module that allows to attach images to any of your models, next you can get images in any sizes, also you can set main image of images set.

Module supports Imagick and GD libraries, you can set up it in module settings.

Usage instance:
---------------

[](#usage-instance)

```
$model = Model::findOne(12); //Model must have id

//If an image is first it will be main image for this model
$model->attachImage('../../image.png');

//But if you need set another image as main, use second arg
$model->attachImage('../../image2.png', true);

//get all images
$images = $model->getImages();
foreach($images as $img){
    //retun url to full image
    echo $img->getUrl();

    //return url to proportionally resized image by width
    echo $img->getUrl('300x');

    //return url to proportionally resized image by height
    echo $img->getUrl('x300');

    //return url to resized and cropped (center) image by width and height
    echo $img->getUrl('200x300');
}

//Returns main model image
$image = $model->getImage();

if($image){
    //get path to resized image
    echo $image->getPath('400x300');

    //path to original image
    $image->getPathToOrigin();

    //will remove this image and all cache files
    $model->removeImage($image);
}
```

Details
-------

[](#details)

1. Get images

    ```
    $model->getImage(); //returns main image for model (first added image or setted as main)

    $model->getImages(); //returns array with images

    //If there is no images for model, above methods will return PlaceHolder images or null
    //If you want placeholder set up it in module configuration (see documentation)
    ```
2. Remove image/images

    ```
    $model->removeImage($image); //you must to pass image (object)

    $model->removeImages(); //will remove all images of this model
    ```
3. Set main image

    ```
    $model->attachImage($absolutePathToImage, true); //will attach image and make it main

    foreach($model->getImages() as $img){
        if($img->id == $ourId){
            $model->setMainImage($img);//will set current image main
        }
    }
    ```
4. Get image sizes

    ```
    $image = $model->getImage();
    $sizes = $image->getSizes(); // Array. Original image sizes
    $sizes = $image->getSizesWhen('x500');
    echo '&lt;img width="'.$sizes['width'].'" height="'.$sizes['height'].'" src="'.$image->getUrl('x500').'" />';
    ```
5. Get original image

    ```
    $img = $model->getImage();
    echo $img->getPathToOrigin();
    ```

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

[](#installation)

1. Add Yii2-images to the require section of your composer.json file:

     ```
        {
             "require": {
                 "panix/mod-images": "dev-master"
             }
        }

    ```
2. run

     ```
       php composer update

    ```
3. run migrate

     ```
     php yii migrate/up --migrationPath=@vendor/panix/mod-images/migrations

    ```
4. setup module

    ```
    'modules' => [
            'images' => [
                'class' => 'panix\mod\images\Module',
                //be sure, that permissions ok
                //if you cant avoid permission errors you have to create "images" folder in web root manually and set 777 permissions
                'imagesStorePath' => 'uploads/store', //path to origin images
                'imagesCachePath' => 'uploads/cache', //path to resized copies
                'graphicsLibrary' => 'GD', //but really its better to use 'Imagick'
                'placeHolderPath' => '@webroot/images/placeHolder.png', // if you want to get placeholder when image not exists, string will be processed by Yii::getAlias
                'imageCompressionQuality' => 100, // Optional. Default value is 85.
                'waterMark' => '@app/web/uploads/watermark.png'
            ],
        ],
    ```
5. attach behaviour to your model (be sure that your model has "id" property)

    ```
        public function behaviors()
        {
            return [
                'image' => [
                    'class' => 'panix\mod\images\behaviors\ImageBehavior',
                ]
            ];
        }
    ```

Thats all!

###  Health Score

26

—

LowBetter than 41% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity11

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity54

Maturing project, gaining track record

 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 ~538 days

Total

2

Last Release

1434d ago

### Community

Maintainers

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

---

Top Contributors

[![andrtechno](https://avatars.githubusercontent.com/u/6948026?v=4)](https://github.com/andrtechno "andrtechno (117 commits)")

---

Tags

pixelion-cms

### Embed Badge

![Health badge](/badges/panix-mod-images/health.svg)

```
[![Health](https://phpackages.com/badges/panix-mod-images/health.svg)](https://phpackages.com/packages/panix-mod-images)
```

###  Alternatives

[goat1000/svggraph

Generates SVG graphs

133890.0k3](/packages/goat1000-svggraph)[costa-rico/yii2-images

yii2 images module for storing images

16062.1k4](/packages/costa-rico-yii2-images)[gravatarphp/gravatar

Gravatar URL builder which is most commonly called as a Gravatar library

12644.1k2](/packages/gravatarphp-gravatar)

PHPackages © 2026

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