function theme_imagezoom_image_multiple in Image Zoom 7
Returns the HTML code for an image with a zoomed version on mouseover.
1 theme call to theme_imagezoom_image_multiple()
- imagezoom_field_formatter_view in ./
imagezoom.module - Implements hook_field_formatter_view().
File
- ./
imagezoom.module, line 254 - Provides an Image Zoom field formatter for Image fields.
Code
function theme_imagezoom_image_multiple($variables) {
if (!variable_get('imagezoom_load_all', 0)) {
drupal_add_js(drupal_get_path('module', 'imagezoom') . '/js/imagezoom.min.js');
}
$display_title = variable_get('imagezoom_display_title', 0);
$hide_thumbs = variable_get('imagezoom_hide_active_thumb', 0);
$settings = array(
'zoom_type' => variable_get('imagezoom_zoom_type', 'popup'),
'display_title' => $display_title,
'hide_thumbs' => $hide_thumbs,
'allow_click' => variable_get('imagezoom_allow_click', 0),
);
drupal_add_js(array(
'imagezoom' => $settings,
), 'setting');
drupal_add_css(drupal_get_path('module', 'imagezoom') . '/css/imagezoom.css');
$items = $variables['items'];
$output = '';
$image = array(
'path' => $items[0]['uri'],
'alt' => $items[0]['alt'],
);
// Do not output an empty 'title' attribute.
if (drupal_strlen($items[0]['title']) > 0) {
$image['title'] = $items[0]['title'];
}
$main_img = '';
if ($variables['display_style']) {
$image['style_name'] = $variables['display_style'];
$main_img = theme('image_style', $image);
}
else {
$main_img = theme('image', $image);
}
$zoom_img = '';
if ($variables['zoom_style']) {
$image['style_name'] = $variables['zoom_style'];
$zoom_img = image_style_url($variables['zoom_style'], $items[0]['uri']);
}
else {
$zoom_img = file_create_url($image['path']);
}
$output .= '<div id="imagezoom-main">';
$options = array(
'html' => TRUE,
'attributes' => array(
'class' => array(
'imagezoom',
),
'rel' => 'nofollow',
),
);
if (isset($image['title'])) {
$options['attributes']['title'] = $image['title'];
}
if (variable_get('imagezoom_colorbox', 0)) {
$options['attributes']['class'][] = 'colorbox';
}
$output .= l($main_img, $zoom_img, $options);
$output .= '</div>';
$thumbs = array();
$classes = array();
foreach ($items as $key => $item) {
$image = array(
'path' => $item['uri'],
'alt' => $item['alt'],
);
// Do not output an empty 'title' attribute.
if (drupal_strlen($item['title']) > 0) {
$image['title'] = $item['title'];
}
// Generate image derivates for the display images
if ($variables['display_style']) {
$image['style_name'] = $variables['display_style'];
$image_style = image_style_load($variables['display_style']);
$derivative_uri = image_style_path($variables['display_style'], $item['uri']);
image_style_create_derivative($image_style, $item['uri'], $derivative_uri);
}
else {
$display_img_path = file_create_url($item['uri']);
}
// Generate image derivates for the zoom images
if ($variables['zoom_style']) {
$image['style_name'] = $variables['zoom_style'];
$image_style = image_style_load($variables['zoom_style']);
$derivative_uri = image_style_path($variables['zoom_style'], $item['uri']);
image_style_create_derivative($image_style, $item['uri'], $derivative_uri);
}
else {
$zoom_img_path = file_create_url($item['uri']);
}
$thumb = '';
if ($variables['thumb_style']) {
$image['style_name'] = $variables['thumb_style'];
$thumb = theme('image_style', $image);
$thumb_path = image_style_url($variables['thumb_style'], $item['uri']);
}
else {
$thumb = theme('image', $image);
$thumb_path = file_create_url($item['uri']);
}
$class = array(
'imagezoom-thumb-image',
);
$hide = '';
if ($key == 0) {
$class[] = 'active';
if ($hide_thumbs) {
$class[] = 'imagezoom-thumb-hide';
}
}
$thumb = l($thumb, $thumb_path, array(
'html' => TRUE,
'attributes' => array(
'rel' => 'nofollow',
),
));
$thumbs[$key] = $thumb;
$classes[$key] = implode(' ', $class);
}
$variables = array(
'items' => $thumbs,
'class' => $classes,
);
if (module_exists('jcarousel') && variable_get('imagezoom_thumb_jcarousel', 0)) {
$variables['jcarousel'] = TRUE;
}
$output .= theme('imagezoom_thumbs', $variables);
return $output;
}