2017 © Pedro Peláez
 

yii2-extension yiiimages

Images manager module for Yii2.

image

makeitbetter/yiiimages

Images manager module for Yii2.

  • Friday, January 19, 2018
  • by makeitbetter
  • Repository
  • 0 Watchers
  • 0 Stars
  • 12 Installations
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 4 Versions
  • 0 % Grown

The README.md

yiiimages

N|Solid, (*1)

Yiiimages is an images manager for Yii framework 2.0. It stores the files in a separate directory. In models images are saved as paths to files relative to this directory. When images is published their thumbnails are created in an accessible via HTTP location., (*2)

Installation

Add package:, (*3)

#!sh
$ composer require makeitbetter/yiiimages

Configure the application by adding (yii2 guide):, (*4)

#!php
$config['modules']['yiiimages'] = [
    'class' => 'makeitbetter\yiiimages\Module',
    'options' => [],
];
$config['bootstrap'][] = 'yiiimages';

Available options:, (*5)

  • sourceFolder - Path to folder where the images will be stored. Default: @app/media.
  • targetFolder - Path relative to web root where the thumbnails will be putted. Default: thumbnails
  • paddingColor - Hexadecimal RGB color to fill thumbnails padding. Default: white, ffffff.
  • getThumbnailPathMethod - Function to create thumbnail items path. It should takes Thumbnail object and returns string. By default class's self method will be applied.
  • maxUploadNumber - Max number of images available to be uploaded at one time.

Next options define parameters for create thumbnails in the manager page (see more in the description of Class Thumbnail ):, (*6)

  • width - Default: 150.
  • height - Default: 150.
  • crop - Default: true.
  • stretch - Default: false.

Configure your translation component (yii2 guide), (*7)

#!php
$config['components']['i18n'] = [
    'translations' => [
        ...
        'modules*' => [
            'class' => 'yii\i18n\PhpMessageSource',
        ],
    ],
];

All module’s phrases translations have a key - modules/yiiimages. So as default you should put you translations to @app/messages/xx-XX/modules/yiiimages.php, (*8)

Finally, distribute permissions: browseImages, addImages, deleteImages. (yii2 guide), (*9)

Usage

In you forms:

#!php
use makeitbetter\yiiimages\widgets\ImageInput;
use yii\widgets\ActiveForm;

$form = ActiveForm::begin();

echo $form->field($model, 'property_name')->widget(ImageInput::className(), $options);

ActiveForm::end();

Or without an ActiveForm object:, (*10)

#!php
echo ImageInput::widget(['model' => $model, 'attribute' => 'property_name']);

Displaying images:

#!php
use makeitbetter\thumbnail\Thumbnail;

echo Thumbnail::of($model->propery_name, 150, 150)->img()

See more about using a Thumbnail helper in the description of class., (*11)

The Versions

19/01 2018

dev-master

9999999-dev http://makeitbetter.su/projects/yiiimages

Images manager module for Yii2.

  Sources   Download

BSD-3-Clause

The Requires

 

The Development Requires

extension yii2 module yii yii 2 makeitbetter images manager

19/01 2018

v1.1

1.1.0.0 http://makeitbetter.su/projects/yiiimages

Images manager module for Yii2.

  Sources   Download

BSD-3-Clause

The Requires

 

The Development Requires

extension yii2 module yii yii 2 makeitbetter images manager

18/07 2017

v1.0.1

1.0.1.0 http://makeitbetter.su/projects/yiiimages

Images manager module for Yii2.

  Sources   Download

BSD-3-Clause

The Requires

 

The Development Requires

extension yii2 module yii yii 2 makeitbetter images manager

14/07 2017

v1.0

1.0.0.0 http://makeitbetter.su/projects/yiiimages

Images manager module for Yii2.

  Sources   Download

BSD-3-Clause

The Requires

 

The Development Requires

extension yii2 module yii yii 2 makeitbetter images manager