function theme_ml_image in Media Library 6
Renders the image tag
Parameters
image - The image array with its properties: preview - wether this is being generated on wysiwyg preview.
1 theme call to theme_ml_image()
- ml_image_filter_media in ml_image/
ml_image.module - Implementation of hook_filter_media()
File
- ml_image/
ml_image.module, line 679 - Media Library Image module.
Code
function theme_ml_image($image, $preview = FALSE) {
$classes = 'ml-image';
$output = '';
// Preview class
if ($preview) {
$classes .= ' ml-image-preview';
// We may receive the object with array structures;
if (is_array($image['attributes'])) {
foreach ($image['attributes'] as $attr => $value) {
$image[$attr] = $value;
}
}
if (is_array($object->metatags)) {
foreach ($object->metatags as $key => $value) {
// To avoid namespace conflitcts, we prefix metatag names with 'meta-'
$tag['meta-' . $key] = $value;
}
}
}
if (!empty($image)) {
// As an example, we use title for everything, but you could use metadata
// like copyright and author info
$alt = $title = $image['title'];
$filepath = $image['filepath'];
// Render the img tag
if ($image['preset'] == 'none') {
$imgtag = theme('image', $filepath, $alt, $title);
}
else {
$imgtag = theme('imagecache', $image['preset'], $filepath, $alt, $title);
}
// Alignment
if (isset($image['align'])) {
$classes .= ' align-' . $image['align'];
}
if (!empty($image['title']) || !empty($image['label'])) {
// Render a box
$classes .= ' box';
$label = !empty($image['label']) ? '<div class="label">' . $image['label'] . '</div>' : '';
$content = '<h2>' . $image['title'] . '</h2>' . $imgtag . $label;
}
else {
$content = $imgtag;
}
}
$output = "<div class=\"{$classes}\">{$content}</div>";
return $output;
}