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:-
[html]
<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.
crops images even when they are smaller then the set size
crops images even when they are smaller then the set size
bug
Property "CWebApplication.simpleImage" is not defined. on /var/www/protected/extensions/thumbnailer/Thumbnailer.php(43): $imgObj = Yii::app()->simpleImage->load($imPath);
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', ),
If you have any questions, please ask in the forum instead.
Signup or Login in order to comment.