Set zoomify as default imagefield node view

mrb@drupal.org - October 25, 2009 - 02:31
Project:Zoomify
Version:6.x-1.x-dev
Component:Miscellaneous
Category:support request
Priority:normal
Assigned:Unassigned
Status:closed
Description

http://drupal.org/node/371818 talks about how to make the zoomify viewer the default display when you view an image node. Our site also has nodes built with cck/Imagefield, and I wanted the same effect for those.

I chose to override theme_imagefield_formatter_image_plain from imagefield_formatter.inc, so in template.php I added:

function YourThemeNameHere_imagefield_formatter_image_plain($element) {
  $node = $element['#node'];
  if ( zoomify_check($node) ) {
    return zoomify_display($node) ;
  }
  else {
    return theme_imagefield_formatter_image_plain($element);
  }
}

Then in my cck content type I go to the 'Display Fields', and select the 'Image' option. Instead of showing the raw image, it now shows the image inside the zoomify viewer.

#1

mrb@drupal.org - October 25, 2009 - 03:05

Spoke too soon! The call to theme_imagefield_formatter_image_plain results in an undefined function. I think the right way to reach it will be via the 'theme' function, but how to force that to use the original function and not the override?

As a quick fix, I just pasted in the original code from function theme_imagefield_formatter_image_plain into the else section:

function YourThemeNameHere_imagefield_formatter_image_plain($element) {
  $node = $element['#node'];
  if ( zoomify_check($node) ) {
    return zoomify_display($node) ;
  }
  else {
    // Inside a view $element may contain null data. In that case, just return.
    if (empty($element['#item']['fid'])) {
      return '';
    }

    $field = content_fields($element['#field_name']);
    $item = $element['#item'];

    $item['data']['alt'] = isset($item['data']['alt']) ? $item['data']['alt'] : '';
    $item['data']['title'] = isset($item['data']['title']) ? $item['data']['title'] : NULL;

    $class = 'imagefield imagefield-'. $field['field_name'];
    return  theme('imagefield_image', $item, $item['data']['alt'], $item['data']['title'], array('class' => $class));
  }
}

#2

kratib - October 25, 2009 - 18:12

Try inserting

module_load_include('inc', 'imagefield', 'imagefield_formatter');

before the call to theme_imagefield_formatter_image_plain.

#3

mrb@drupal.org - October 29, 2009 - 02:11

That fixes it - thanks for the help. So the working version is:

function YourThemeNameHere_imagefield_formatter_image_plain($element) {
  $node = $element['#node'];
  if ( zoomify_check($node) ) {
    return zoomify_display($node) ;
  }
  else {
    module_load_include('inc', 'imagefield', 'imagefield_formatter');
    return theme_imagefield_formatter_image_plain($element);
  }
}

#4

mrb@drupal.org - October 29, 2009 - 02:14
Status:active» closed
 
 

Drupal is a registered trademark of Dries Buytaert.