easyimage Extension for easy creating and caching thumbnails on real time.

  1. Features:
  2. Requirements
  3. Resources
  4. Installing and configuring
  5. Usage

You don't need to create many types of thumbnails for images in your project. You can create a thumbnail directly in the View. Thumbnail will automatically cached. It's easy!

Features:

  • Easy to use
  • Support GD and Imagick
  • Automaticly thumbnails caching
  • Cache sorting to subdirectories
  • Support Retina displays
  • Based on Kohana Image Library.

Requirements

  • Yii 1.1 or above
  • GD or Imagick

Resources

Note: Latest release and documentation are available from extension github page.

Installing and configuring

Extract the EasyImage folder under protected/extensions

Add the following to your config file components section:

'components'=>array(
    //...
    'easyImage' => array(
        'class' => 'application.extensions.easyimage.EasyImage',
        //'driver' => 'GD',
        //'quality' => 100,
        //'cachePath' => '/assets/easyimage/',
        //'cacheTime' => 2592000,
        //'retinaSupport' => false,
),

and the following to import section:

'import' => array(
    //...
    'ext.easyimage.EasyImage'
),

Usage

InstanceOf
$image = new EasyImage('/path/to/image.jpg');
$image->resize(100, 100);
$image->save('/full/path/to/thumb.jpg');
Parameters
  • string $file required - Image file path
  • string $driver - Driver: GD, Imagick
ThumbOf

You can create a thumbnail directly in the View:

// Create and autocache
Yii::app()->easyImage->thumbOf('/path/to/image.jpg', array('rotate' => 90));

// or
Yii::app()->easyImage->thumbOf('image.jpg', array('rotate' => 90),  array('class' => 'image'));

// or
Yii::app()->easyImage->thumbOf('image.png',
    array(
        'resize' => array('width' => 100, 'height' => 100),
        'rotate' => array('degrees' => 90),
        'sharpen' => 50,
        'background' => '#ffffff',
        'type' => 'jpg',
        'quality' => 60,
    ));

Note. This method return CHtml::image()

Parameters
  • string $file required - Image file path
  • array $params - Image manipulation methods. See Methods
  • array $htmlOptions - options for CHtml::image()
ThumbSrcOf
Yii::app()->easyImage->thumbSrcOf('image.jpg', array('crop' => array('width' => 100, 'height' => 100)));

Note. This method return path to image cached.

Parameters
  • string $file required - Image file path
  • array $params - Image manipulation methods. See Methods
12 0
23 followers
762 downloads
Yii Version: Unknown
License: BSD-2-Clause
Category: User Interface
Developed by: Artur Zhdanov
Created on: May 16, 2013
Last updated: 4 years ago

Related Extensions