Personal License $11.99

1 site, unlimited servers No source distribution Commercial use allowed Can modify source Read full license | More Info

Developer License $44.99

Unlimited projects Source and binary distribution Commercial use allowed Distribute modifications Read full license | More Info

You need to log-in or create an account
  • Create an account
  • Log-in
  • Please use your real name.
  • Account activation link will be sent to this address.
  • Minimum 8 characters

Clicking this button confirms you read and agreed to the terms of use and privacy policy.

Starting from $ 11.99

View Pricing 14 days money-back guarantee

Thumbnail Action Helper

A thumbnail creation / display action helper for the Zend Framework

Share and win up to $15k in prizes each month!Learn more

Share

Description

An action helper for the Zend Framework for easy resizing of images into file thumbnails or for direct display.

Features:

  • Very simple, one-line resizing!
  • Supported formats include JPG, GIF and PNG
  • Supports transparency
  • Automatic proportion resizing if given only one of the dimensions (height or width)
  • Uses the GD library (note: must be enabled on the server to run)
Back to top

Setup and usage

In order to use this action helper you must add the 'Razor' namespace to your application autoloader namespaces. Add the following line it in your application.ini :

autoloaderNamespaces[] = "Razor_"

In order to automatically load all the helpers inside the directory Razor/Controller/Action/Helper, add the following line to the configuration as well :

resources.frontController.actionHelperPaths.Razor_Controller_Action_Helper = "Razor/Controller/Action/Helper"

Copy the 'Razor' library inside your library folder - your application tree will looks like something like this :

-- application 
   -- configs
   -- controllers
   -- models
   -- views
-- library
   -- Zend
   -- Razor

The action helper accepts four parameters :

  1. ( mandatory ) The full path of the source image
  2. ( optional ) The destination path of the resized image
  3. ( optional ) The resized image width
  4. ( optional ) The resized image height

If the second parameter is omitted or empty, the image in rendered directly and not saved on the filesystem.

If you specify both width and height you will get a new image of the specified width and height. If you omit both, the result image is the same width and height of the source. If you specify only width OR only height the dimension not specified is automatically calculated to maintain proportions.

Sample usage #1 - Image is rendered straight to the browser

$imageToMinify = // Your image fullpath
$this->_helper->Thumbnail( $imageToMinify );

Sample usage #2 - Image is saved to a destination and height is calculated by the helper

$imageToMinify = // Your image fullpath
$destination = // Your resized image destination
$width = 640; // width of the new image
$this->_helper->Thumbnail( $imageToMinify, $destination, $width );

Questions & Comments

Leave a comment

You must be logged-in to leave a comment.
Log-in now or register for a free account.
No comments have been posted yet.
You must be logged-in to vote. Log-in to your account or register now.

User Reviews

No reviews have been submitted yet.

Starting from $ 11.99

View Pricing 14 days money-back guarantee