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.

Comments

davidhk’s picture

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));
  }
}
infojunkie’s picture

Try inserting

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

before the call to theme_imagefield_formatter_image_plain.

davidhk’s picture

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); 
  }
}
davidhk’s picture

Status: Active » Closed (fixed)