Return to Snippet

Revision: 46859
at May 26, 2011 22:51 by kfiil


Initial Code
/**
 * Theme a image from a CCK Image Field with either theme('image'...) or theme('imagecache'...)
 * 
 * @param array $imageCckField The CCK Image field array usually called with: $node->field_tools_image[0] for example
 * @param array $attributes Associative array of attributes to be placed in the img tag for example array('class' => 'link')
 * @param string Imagecache preset

 * @return string A string containing the image tag.
 * 
 * @link http://api.drupal.org/api/drupal/includes--theme.inc/function/theme_image/6 theme_image
 * @link http://drupal.org/node/163561 Imagecache: dynamic image manipulation
 */
function _fremtidslaboratoriet_themeImage($imageCckField, $attributes = array(), $imagecachePreset = NULL)
{
	$returnValue = NULL;
	$filepath = $imageCckField['filepath'];
	$alt = $imageCckField['data']['alt'];
	$title = $imageCckField['data']['title'];
	
	if(!$filepath)
	{
		return NULL;
	}
	
	if ($imagecachePreset == NULL)
	{
	    $returnValue = theme('image', $filepath, $alt, $title, $attributes);	   
	}
	else
	{
		$returnValue = theme('imagecache', $imagecachePreset,$filepath, $alt, $title,  $attributes); 
	}
	
	return $returnValue;
}

Initial URL

                                

Initial Description

                                

Initial Title
Theme a image from a CCK Image Field with either theme('image'...) or theme('imagecache'...)

Initial Tags
template, drupal

Initial Language
PHP