Image view helper for Zend Framework

Image view helper to generate an image tag

Arguments to pass are:

  1. Uniqe name for the image tag. Will be the id attribute.
  2. Path to the image file.
  3. Tag Attributes. (alt tag is required and it will generate the title tag with the same value)
  4. Optional string parameter. Currently if you enter thumnail it will create a thumnail if its not exists and display it.

Click here to view the class code.

Click here to download the code.

Usage:

Basic usage:

echo $this->image('name', 
                          'path/to/image.jpg', 
                          array('alt' => 'image alt'));

To create product thumbnail image.

 echo $this->image('name', 
                           'img/products/1.jpg', 
                           array('alt' => 'image alt'), 
                           'thumbnail');

Any comments and improvement are welcome :)

Leave A Reply

Comments

Mhd zaher ghaibeh (Apr 23, 2010)

hi Mohammad :
you have a typo :
“$thi–>_name = $this->view->;escape($name); “.
must be :
“$this->_name = $this->view->escape($name);”

plus i hope you can provide the code as a downloaded package.

but its looks nice :D

Tags