* @version $Id$ * @license http://framework.zend.com/license/new-bsd New BSD License */ /** Zend_View_Helper_HtmlElement */ require_once 'Zend/View/Helper/HtmlElement.php'; /** * Helper for generating valid image HTML tags. * * @package Recipe_Helper * @subpackage View */ class Recipe_Helper_View_Image extends Zend_View_Helper_HtmlElement { /** * HTML attributes. * * @var array */ protected $_attributes = array(); /** * Creates an HTML image tag. * * @param string $src The image source URL * @param integer $width Width attribute * @param integer $height Height attribute * @param string $title alt+title attribute content * @param array $additionalAttribues Any additional attributes * * @return Recipe_Helper_View_Image */ public function image($src, $width = null, $height = null, $title = null, array $additionalAttribues = null) { $alt = $title; $attribues = compact('src', 'width', 'height', 'title', 'alt'); if($additionalAttribues !== null) $attribues += $additionalAttribues; $this->setAttributes($attribues); return $this; } /** * Set the attributes for image tag. * * @param array $attributes Key-Value pairs * * @return Recipe_Helper_View_Image */ public function setAttributes(array $attributes) { $this->_attributes = $attributes; return $this; } /** * Returns the attributes. * * @return array */ public function getAttributes() { return $this->_attributes; } /** * Generates the HTML tag for an image. * * @return string */ public function __toString() { return '_htmlAttribs($this->getAttributes()).$this->getClosingBracket(); } }