function theme_imagezoomer_power_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_power_image()
- imagezoomer_field_formatter_view in ./
imagezoomer.module - Implements hook_field_formatter_view().
File
- ./
imagezoomer.module, line 262 - Integrate Powerzoomer / Featuredzoom jquery plugins to Drupal 7
Code
function theme_imagezoomer_power_image($variables) {
// Validate inputs.
if (is_null($variables['file']) or is_null($variables['image_style_display'])) {
drupal_set_message(t('Powerzoomer 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'];
$imagezoomer_options = !is_array($variables['imagezoomer_power_options']) ? array() : $variables['imagezoomer_power_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', 'ddpowerzoomer');
// Adding options to Drupal.settings for JQuery script uses.
if (empty($imagezoomer_options)) {
$imagezoomer_options = array(
'imagezoomer_power_default_power' => variable_get('imagezoomer_power_default_power', 2),
'imagezoomer_power_power_range_low' => variable_get('imagezoomer_power_power_range_low', 2),
'imagezoomer_power_power_range_high' => variable_get('imagezoomer_power_power_range_high', 7),
'imagezoomer_power_magnifier_size_width' => variable_get('imagezoomer_power_magnifier_size_width', 75),
'imagezoomer_power_magnifier_size_height' => variable_get('imagezoomer_power_magnifier_size_height', 75),
);
}
$imagezoomer_options = array(
'image-id-' . $file->fid => array(
'imagezoomer_power_default_power' => isset($imagezoomer_options['imagezoomer_power_default_power']) ? $imagezoomer_options['imagezoomer_power_default_power'] : variable_get('imagezoomer_power_default_power', 2),
'imagezoomer_power_power_range_low' => isset($imagezoomer_options['imagezoomer_power_power_range_low']) ? $imagezoomer_options['imagezoomer_power_power_range_low'] : variable_get('imagezoomer_power_power_range_low', 2),
'imagezoomer_power_power_range_high' => isset($imagezoomer_options['imagezoomer_power_power_range_high']) ? $imagezoomer_options['imagezoomer_power_power_range_high'] : variable_get('imagezoomer_power_power_range_high', 7),
'imagezoomer_power_magnifier_size_width' => isset($imagezoomer_options['imagezoomer_power_magnifier_size_width']) ? $imagezoomer_options['imagezoomer_power_magnifier_size_width'] : variable_get('imagezoomer_power_magnifier_size_width', 75),
'imagezoomer_power_magnifier_size_height' => isset($imagezoomer_options['imagezoomer_power_magnifier_size_height']) ? $imagezoomer_options['imagezoomer_power_magnifier_size_height'] : variable_get('imagezoomer_power_magnifier_size_height', 75),
),
);
drupal_add_js(array(
'imagezoomer_power' => $imagezoomer_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 = NULL;
if (!is_null($image_style_zooming)) {
$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-power-image" id="imagezoomer-power-image-' . $file->fid . '" alt="' . $file->filename . '" title="' . $file->filename . '" />';
if (!is_null($zooming_image_path)) {
$output .= '<img src="' . $zooming_image_path . '" border="0" class="imagezoomer-power-zoomer-image" id="imagezoomer-power-zoom-image-' . $file->fid . '" alt="' . $file->filename . '" title="' . $file->filename . '" style="display:none" />';
}
return $output;
}