CoreFiles by mySites.guru
Img.php73 lines, 1,652 bytes, from Joomla_1.5.21-Stable-Full_Package.zip
Raw History Compare with 1.5.20
md5
6f8ee47c205586087eff5123a4607b00
sha1
ff4b395524f083f429e615e04671f6850b1f61e6
sha256
502c56754be9351beb47e04e3a6cd030f11eb9adccae5388b7f42aebfd9edd4f
<?PHP
/**
 * patTemplate function that returns a complete imagetag and
 * width and height are extracted from the image
 *
 * $Id: Img.php 10381 2008-06-01 03:35:53Z pasamio $
 *
 * @package		patTemplate
 * @subpackage	Functions
 * @author		Jens Strobel <[email protected]>
 */

// Check to ensure this file is within the rest of the framework
defined('JPATH_BASE') or die();

/**
 * patTemplate function that returns a complete imagetag and
 * width and height are extracted from the image
 *
 * $Id: Img.php 10381 2008-06-01 03:35:53Z pasamio $
 *
 * @package		patTemplate
 * @subpackage	Functions
 * @author		Jens Strobel <[email protected]>
 */
class patTemplate_Function_Img extends patTemplate_Function {
	/**
	* name of the function
	* @access	private
	* @var		string
	*/
	var $_name	  =	'Img';

	/**
	* defaults for some tags
	*
	* @access	protected
	* @var	array
	*/
	var $_defaults = array();

	/**
	* call the function
	*
	* @access	public
	* @param	array	parameters of the function (= attributes of the tag)
	* @param	string	content of the tag
	* @return	string	content to insert into the template
	*/
	function call ($params, $content)
	{
		$src= $params['src'] ? $params['src'] : $content;
		list($width, $height, $type, $attr)= getimagesize($src);

		$this->_defaults= array(
		  'border' => 0,
		  'title'  => '',
		  'alt'    => '',
		  'width'  => $width,
		  'height' => $height
		);

		$params = array_merge($this->_defaults, $params);
		$tags= '';
		foreach ($params as $key => $value){
		  $tags.= sprintf('%s="%s" ', $key, htmlentities($value));
		}
		$imgstr= sprintf('<img %s/>', $tags);

		return $imgstr;
	}
}
?>

The same content is in 23 releases, Joomla 1.5.4 to 1.5.26. See them all, or every version of this file.