function theme_emimage_image in Embedded Media Field 6.3
Same name and namespace in other branches
- 6 contrib/emimage/emimage.theme.inc \theme_emimage_image()
- 6.2 contrib/emimage/emimage.theme.inc \theme_emimage_image()
Helper theme for various emimage themes.
3 theme calls to theme_emimage_image()
- theme_emimage_image_full in contrib/
emimage/ emimage.theme.inc - Format the image using the Full Image preset.
- theme_emimage_image_preview in contrib/
emimage/ emimage.theme.inc - Format the image using the Preview Image preset.
- theme_emimage_image_thumbnail in contrib/
emimage/ emimage.theme.inc - Format the image using the Thumbnail presets.
File
- contrib/
emimage/ emimage.theme.inc, line 11 - Theme functions for Embedded Media Image
Code
function theme_emimage_image($field, $item, $formatter, $node, $code, $width = NULL, $height = NULL, $title = '', $link = NULL, $options = array()) {
$url = module_invoke('emfield', 'include_invoke', 'emimage', $item['provider'], 'image_url', $code, $width, $height, $formatter, $field, $item, $node);
$attributes = array();
if ($width) {
$attributes['width'] = $width;
}
if ($height) {
$attributes['height'] = $height;
}
if (!isset($width) || !isset($height)) {
// Find out the size of the actual image file, and scale accordingly
if ($item['data']['width'] && $item['data']['height']) {
// The image's width & height are known
$scale_width = $item['data']['width'] / ($width ? $width : 1);
$scale_height = $item['data']['height'] / ($height ? $height : 1);
if ($scale_width > $scale_height) {
$attributes['width'] = $width;
}
else {
$attributes['height'] = $height;
}
}
else {
// We don't know the size of the image, so just make it fill the space available.
// It will probably be stretched in one direction, making it look odd.
$attributes['width'] = $width ? $width : NULL;
$attributes['height'] = $height ? $height : NULL;
}
}
if ($item['class']) {
$attributes['class'] = $item['class'];
}
else {
if ($item['provider']) {
$attributes['class'] = $item['provider'];
}
}
$output = theme('image', $url, $title, $title, $attributes, false);
if ($link) {
$output = l($output, $link, array(
'html' => true,
));
}
return $output;
}