Trying to get this working with Drupal 5.2 and Image Assist. When I click on the image I get the gray background and a white box but that's as far as it goes (see attached screenshot). This is viewing with Firefox 2.0. If I click the white box then it clears correctly back to the page. Any ideas where I'm going wrong?

(Aside: if I click on the white square before the background has reached the darkest shade of gray then everything just locks up and I have to refresh the page to clear back to the page.)

Thanks,
Dave

CommentFileSizeAuthor
lightbox.png47.78 KBdjc

Comments

djc’s picture

Okay - I'm guessing that the problem is that the anchor wrapped round the image is to the image node and not directly to the image itself (having selected "Link to image page" in the Image Assist popup when adding the image). However, even if I wanted to link directly to the image (and I don't, as for non-JavaScript I'd rather they went to the image node), I don't see how I would given the options Image Assist provides: "Not a link", "Link to image page", "Open in popup window", "Go to URL"; unless I used the last of these and entered the URL of the image explicitly (thereby avoiding most of the assistance it provides!). This project claims it supports Image Assist - at the moment I'm failing to see how!

Dave

sun’s picture

I see. Currently, Image Assist only links to the actual image if you select "open in popup window". If jLightbox is enabled, it will parse all linked images in a content and attaches the Lightbox behaviour to them. Thus, the user will see the image(s) in Lightbox instead of a popup window.

Lightbox basically depends on the anchor linking to the image. This means, that having both Lightbox working and a separate link to an image node for users without JavaScript is not possible.

sun’s picture

Component: JavaScript » Documentation
Assigned: Unassigned » sun
Status: Active » Fixed

Committed this extra info to README.txt:

  Note: You need to select "Open in popup window" in Image Assist to let
  Lightbox properly work with inline images.
sun’s picture

Title: Just see a white box » Provide hook for adding link (output) types by other modules
Project: jQuery Lightbox » Image Assist
Version: 5.x-1.0 » 5.x-1.x-dev
Component: Documentation » Code
Assigned: sun » Unassigned
Category: support » feature
Status: Fixed » Active

Image Assist currently provides the options "Not a link", "Link to image page", "Open in popup window" and "Go to URL" only. In the meantime, there are plenty of other modules (such as jQuery Lightbox) that might need to add output options to this list.

In case of jLightbox, a user has to select "Open in popup window" to achieve the desired behaviour. However, the Image Assist popup window handler is added to all image links using this option, which is actually needless then.

I'd like to propose a new hook_img_assist_link_properties() and hook_img_assist_link_output() that let other modules add custom output formats for inline images.

So basically, by converting default link properties into this hook:

img_assist_img_assist_link_properties() {
  return array(
    'none' => t('Not a link'),
    'node' => t('Link to image page'),
    'popup' => t('Open in popup window'),
    'url' => t('Go to URL')
  );
}

img_assist_img_assist_link_output($node, $size, $img_tag, $attributes) {
  $output = '';
  $link = explode(',', $attributes['link']);

  if ($link[0] == 'node') {
    $output .= l($img_tag, "node/" . $node->nid, array(), NULL, NULL, FALSE, TRUE);
  }
  elseif ($link[0] == 'popup') {
    $popup_size = variable_get('img_assist_popup_label', IMAGE_PREVIEW);
    $info = image_get_info(file_create_path($node->images[$popup_size]));
    $width = $info['width'];
    $height = $info['height'];
    $url = file_create_url($node->images[variable_get('img_assist_popup_label', IMAGE_PREVIEW)]);
    $output .= l($img_tag, $url, array('onclick' => "launch_popup($node->nid, $width, $height); return false;", 'target' => '_blank'), NULL, NULL, FALSE, TRUE);
  }
  elseif ($link[0] == 'url') {
    $output .= l($img_tag, $link[1], array(), NULL, NULL, FALSE, TRUE);
  }
  else {
    $output .= $img_tag;
  }

  return $output;
}
drewish’s picture

subscribing... i'd be interested in making this a more standardized hook. i've got similar code in the image module that i'd like to open up.

sun’s picture

@drewish: Do you already have more detailed requirements for these hooks than those I exemplary copied from img_assist? I just had a quick look into image.module and did not find a function that outputs images with different properties/links.

To make things even more complicated (tm), maybe we should simply adopt cck's field formatter functions? If we would do that, we would automatically implement all possible output styles for Imagefields, too.

djc’s picture

I don't know if it's because I'm using the latest dev versions of image and image assist but the popup option doesn't work for me. If you look at the generated link then it's probably not surprising:

djc’s picture

Let's see if it allows me to include the anchor this time...

<a href="http://localhost:82/files/" onclick="launch_popup(9, , ); return false;" target="_blank">

drewish’s picture

sun, it's an option in the newer version of the image module. there's no hook yet... that was what i'd been thinking about adding.

sun’s picture

@djc: That's another issue. You may subscribe to this issue to stay up2date.

@drewish: Do you mean the column "Link" in the image settings where one is able to select a target window? If it is, then I'm a bit afraid that the generated links do not contain an image (i.e. <a><img /></a>) in the output. AFAIK, they only link to the same node with an additional parameter. However, if you think that it would be valuable to abstract image links and images, we can certainly go that way, too.

@all: What's your opinion about re-using CCK's field formatter function schema? Of course, our (image*) modules would have to implement an additional default argument for hook_field_formatter_info() to have them not included by CCK. F.e.:

function hook_field_formatter_info($cck = TRUE) {
  if ($cck) {
    return array();
  }
  $formatters = array();
  $formatters['none'] = array(
    'label' => t('None'),
    'field types' => array('image'),
  );
  $formatters['node'] = array(
    'label' => t('Link to image page'),
    'field types' => array('image'),
  );
  $formatters['popup'] = array(
    'label' => t('Open in popup window'),
    'field types' => array('image'),
  );
  $formatters['url'] = array(
    'label' => t('Go to URL'),
    'field types' => array('image'),
  );
  
  return $formatters;
}

To learn more about CCK's field formatter functions, you might have a look into jQuery lightbox or Imagefield modules.