function theme_imagezoomer_featured_image in Image Zoomer 7
Provides a theme function to return an image with powerzoomer attached. @params: $file - Drupal file object. $image_style: The imagecache style name for showing the image on the page. $image_zoom_style: The imagecache style name for zoomming when mouseover. (leave empty for not using bigger zooming image).
1 theme call to theme_imagezoomer_featured_image()
- imagezoomer_field_formatter_view in ./
imagezoomer.module - Implements hook_field_formatter_view().
File
- ./
imagezoomer.module, line 201 - Integrate Powerzoomer / Featuredzoom jquery plugins to Drupal 7
Code
function theme_imagezoomer_featured_image($variables) {
// Validate inputs.
if (is_null($variables['file']) or is_null($variables['image_style_display'])) {
drupal_set_message(t('Power featured zoomer image cannot be set. Please double check input data.'), 'error');
return '';
}
// Get variables.
$file = $variables['file'];
$image_style_display = $variables['image_style_display'];
$image_style_zooming = $variables['image_style_zooming'];
$featuredzoomer_options = !is_array($variables['imagezoomer_featured_options']) ? array() : $variables['imagezoomer_featured_options'];
// Convert $file object.
if (!is_object($file)) {
$file = (object) $file;
}
// Adding our required js files.
drupal_add_js(drupal_get_path('module', 'imagezoomer') . '/imagezoomer.js');
drupal_add_library('imagezoomer', 'featuredzoomer');
// Adding options to Drupal.settings for JQuery script uses.
if (empty($featuredzoomer_options)) {
$featuredzoomer_options = array(
'imagezoomer_featured_power_range_low' => variable_get('imagezoomer_featured_power_range_low', 2),
'imagezoomer_featured_power_range_high' => variable_get('imagezoomer_featured_power_range_high', 7),
'imagezoomer_featured_magnifier_size_width' => variable_get('imagezoomer_featured_magnifier_size_width', 200),
'imagezoomer_featured_magnifier_size_height' => variable_get('imagezoomer_featured_magnifier_size_height', 200),
'imagezoomer_featured_magnifier_position' => variable_get('imagezoomer_featured_magnifier_position' . 'right'),
);
}
$featuredzoomer_options = array(
'imagezoomer_featured_power_range_low' => isset($featuredzoomer_options['imagezoomer_featured_power_range_low']) ? $featuredzoomer_options['imagezoomer_featured_power_range_low'] : variable_get('imagezoomer_featured_power_range_low', 2),
'imagezoomer_featured_power_range_high' => isset($featuredzoomer_options['imagezoomer_featured_power_range_high']) ? $featuredzoomer_options['imagezoomer_featured_power_range_high'] : variable_get('imagezoomer_featured_power_range_high', 7),
'imagezoomer_featured_magnifier_size_width' => isset($featuredzoomer_options['imagezoomer_featured_magnifier_size_width']) ? $featuredzoomer_options['imagezoomer_featured_magnifier_size_width'] : variable_get('imagezoomer_featured_magnifier_size_width', 200),
'imagezoomer_featured_magnifier_size_height' => isset($featuredzoomer_options['imagezoomer_featured_magnifier_size_height']) ? $featuredzoomer_options['imagezoomer_featured_magnifier_size_height'] : variable_get('imagezoomer_featured_magnifier_size_height', 200),
'imagezoomer_featured_magnifier_position' => isset($featuredzoomer_options['imagezoomer_featured_magnifier_position']) ? $featuredzoomer_options['imagezoomer_featured_magnifier_position'] : variable_get('imagezoomer_featured_magnifier_position', 'right'),
);
drupal_add_js(array(
'imagezoomer_featured' => $featuredzoomer_options,
), 'setting');
// Get image path for displaying and zooming image.
$displaying_image_path = $image_style_display == 'original' ? file_create_url($file->uri) : image_style_url($image_style_display, $file->uri);
$zooming_image_path = $image_style_zooming == 'original' ? file_create_url($file->uri) : image_style_url($image_style_zooming, $file->uri);
// Theme both images for showing.
$output = '';
$output .= '<img src="' . $displaying_image_path . '" border="0" class="imagezoomer-featured-image" id="imagezoomer-featured-image-' . $file->fid . '" alt="' . $file->filename . '" title="' . $file->filename . '" zoomingpath="' . $zooming_image_path . '" />';
return $output;
}