Yii 1.1: thumbnailer

Replace <img> tags on the fly with generated thumbnails and a link to the image. Useful with fancybox extension.
9 followers

Replace <img> tags on the fly with auto generated thumbnails and a link to the image. Useful with the fancybox extension.

Requirements

Yii 1.1 or above.

Usage

<?php $this->beginWidget('application.extensions.thumbnailer.Thumbnailer', array(
 
        'thumbsDir' => 'images/thumbs',
        'thumbWidth' => 200,
        'thumbHeight' => 150, // Optional
    )
); ?>
 
// This portion is captured by the widget
<img src="images/example.jpg" />
<img src="images/anotherExample.jpg" />
<img src="images/yetAnotherExample.jpg" />
 
// Replace the images with thumbnails
<?php $this->endWidget(); ?>

This outputs:-

<a href="images/example.jpg" rel="gallery">
    // The thumbnail images are created when the page is loaded for the first time!
    // To create the thumbnail, simpleimage is used.
    <img src="images/thumbs/example.jpg">
</a>
<a href="images/anotherExample.jpg" rel="gallery">
    <img src="images/thumbs/anotherExample.jpg">
</a>
<a href="images/yetAnotherExample.jpg" rel="gallery">
    <img src="images/thumbs/yetAnotherExample.jpg">
</a>

Resources

The following extension must be installed:-

Credits

  • phpQuery is used internally by the extension. A distribution of phpQuery is included in the zip file.

Total 3 comments

#7681 report it
saegeek at 2012/04/09 03:29am
fixed

Hi, Check my fixed version, it works better with paths like href="/images" : http://mir.cr/1GTEYMHJ

Unzip all files to /protected/extensions/ Don't forget to add this (into config/main.php) :

'components'=>array(
                'simpleImage'=>array(
                        'class' => 'application.extensions.CSimpleImage',
                ),
#7679 report it
saegeek at 2012/04/09 02:26am
bug
Property "CWebApplication.simpleImage" is not defined. 
 
on /var/www/protected/extensions/thumbnailer/Thumbnailer.php(43):
 
$imgObj = Yii::app()->simpleImage->load($imPath);
#7379 report it
Vince. at 2012/03/18 07:38pm
crops images even when they are smaller then the set size

crops images even when they are smaller then the set size

Leave a comment

Please to leave your comment.

Create extension