Image Caption uses hook_nodeapi to trigger the loading of the JavaScript. If you use Panels to override the ode display for certain content types (quite common), then the JS does not load, as hook_nodeapi() does not fire with the view op - it only uses the load op.

Another way could be to use something like

function image_caption_init() {
  if (arg(0) == 'node' && is_numeric(arg(1)) & !arg(2)) {
    ....
  }
}

Untested, but quite standard for detecting if you are on a node view page - technique used throughout core.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

mrfelton’s picture

Status: Active » Needs review
FileSize
1.03 KB

Patch attached.

jemond’s picture

Status: Needs review » Reviewed & tested by the community

I can confirm this works in production.

jemond’s picture

Since this patch is two years old and the module hasn't had a commit in a year, I went with a custom module fix for this issue that uses a slightly difference approach:

function MODULENAME_init() {
  if ($node = menu_get_object('node')) {
    if (module_exists('image_caption') && in_array($node->type, variable_get('image_caption_node_types', array()))) {  
      $path = drupal_get_path('module', 'image_caption');
      drupal_add_js($path.'/image_caption.js','module', 'header');
    }
  }
}