Gets the imagecache image style for the selected image.
Get raw version
php
/** * Apply a media style to a node's image URI, and return that image's HTML tag */ function get_image_media_style($style, $field, $node){ $l = isset($node->language) ? $node->language : LANGUAGE_NONE; if (!isset($node->{$field}[$l]['0']['uri'])) return ''; // Get the image URI from the node. $uri = $node->{$field}[$l]['0']['uri']; // Get the image Title and Alt texts $alt = !empty($node->{$field}[$l]['0']['alt']) ? $node->{$field}[$l]['0']['alt'] : ''; $title = !empty($node->{$field}[$l]['0']['title']) ? $node->{$field}[$l]['0']['title'] : ''; // Prepare and call the imagecache style $data = array( 'style_name' => $style, 'path' => $uri, 'width' => '', 'height' => '', 'alt' => $alt, 'title' => $title, ); // Generate and return the image source $image = theme_image_style($data); return $image; }
Comments
agoradesign (not verified) commented 5 years 2 months ago
Better solution would be to change the last line in:
$image = theme('image_style', $data);
Now custom theme overrides could be used