Image view helper to generate an image tag
Arguments to pass are:
- Uniqe name for the image tag. Will be the id attribute.
- Path to the image file.
- Tag Attributes. (alt tag is required and it will generate the title tag with the same value)
- 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 🙂
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 😀