Plugin · Mecha CMS

A lower priority extensions.

Thumbnail

Author: Taufik Nurrohman · 319 Views

Tweet

Resize and crop images on the fly.

Download Development Version

URL Pattern 

  • /t/{$width}/{$path} → proportional image resize
  • /t/{$width}/{$height}/{$path} → proportional image resize and crop
  • /t/{$x}/{$y}/{$width}/{$height}/{$path} → crop image without resize

Example 

http://mecha-cms.com/t/200/path/to/image.jpg
http://mecha-cms.com/t/200/200/path/to/image.jpg
http://mecha-cms.com/t/30/60/200/400/path/to/image.jpg

Description 

  • {$width} → the image width
  • {$height} → the image height
  • {$x} → horizontal position from the original image corner
  • {$y} → vertical position from the original image corner
  • {$path} → the image path relative to the ASSET folder.

Converter 

Convert default image URL into image thumbnail URL:

To::thumbnail($in, $size);
To::thumbnail($in, $width, $height);
To::thumbnail($in, $x, $y, $width, $height);

Example:

<?php $path = 'http://mecha-cms.com/lot/asset/jpg/city.jpg'; ?>

<img alt="" src="<?php echo To::thumbnail($path, 50); ?>">
<img alt="" src="<?php echo To::thumbnail($path, 50, 50); ?>">
<img alt="" src="<?php echo To::thumbnail($path, 10, 10, 50, 50); ?>">

Dependency 

Extension