resizer Simple images resizer extension

  1. Why can you need it?
  2. Requirements
  3. Usage
  4. Summary

Why can you need it?

Have an images gallery?
Tired of thinking what images sizes will you need?
Waste your time changing sizes and regenerating images?

This simple extension allows you to forget about this problems.
All you will need is to keep base (original) image.

Resizer extension will generate image whatever size you need, just on fly!

Requirements

You will need:

  • Yii 1.1 or above
  • GD extension
  • Yii urlManager urlFormat must be set to path

Usage

  1. Move extension to /protected/extensions/resizer/

  2. To use this extension you will need some controller. Extension is installed as controller action. Let's assume our controller name is test, and we will use resized action as name.

In your controller you need to add:

public function actions()
{
    return array(
        'resized' => array(
            'class'   => 'ext.resizer.ResizerAction',
            'options' => array(
                // Tmp dir to store cached resized images 
                'cache_dir'   => Yii::getPathOfAlias('webroot') . '/assets/',

                // Web root dir to search images from
                'base_dir'    => Yii::getPathOfAlias('webroot') . '/',
            )
        ),
    );
}

Let's assume you have an image http://domain/images/big.png.

To get 100x100 icon, use the following URL :

http://domain/test/resized/100x100/images/big.png

So, as you see, URL structure is:

http://SERVER_NAME/CONTROLLER_ID/ACTION_ID/WIDTHxHEIGHT/PATH_TO_IMAGE

Summary

May have some bugs. Please, report them or ask questions.

2 1
8 followers
1 216 downloads
Yii Version: 1.1
License: GPL-2.0
Category: File System
Developed by: ASAP
Created on: Feb 20, 2013
Last updated: 11 years ago

Downloads

show all

Related Extensions