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 🙂

Posted in PHP, Zend Framework and tagged , , .
Loading Facebook Comments ...

Leave a Reply

Your email address will not be published. Required fields are marked *

One Comment

  1. 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 😀