Img_assist and JavaScript Popups

Ah the age old problem of having popup windows on your thumbnails. I figured out a good way to do this with some modifications of the img_assist plugin.

Change line 813:
$img_template = t($img_template, array('%caption' => $vars['caption'], '%node-link' => url("node/$image->nid"), '%img-link' => $image->filepath, '%alt' => check_plain($vars['alt']), '%width' => $width, '%height' => $height, '%src' => $src, '%image-class' => $class));

To
$img_template = t($img_template, array('%caption' => $vars['caption'], '%node-link' => url("node/$image->nid"), '%img-link' => $image->filepath, '%alt' => check_plain($vars['alt']), '%width' => $width, '%height' => $height, '%src' => $src, '%image-class' => $class, '%orig_src' => file_create_url($image->filepath), '%orig_height' => $image->height, '%orig_width' => $image->width));

Now, we just need to add support in the img_assist configuration.

%alt

%caption


And finally, a JavaScript function to tie it all together:


function openWindow(url, name, w, h, perc, scrollbars) {
  // initialize winX and winY to default values
  // for cases where Screen object isn't supported
  var winX = 0;
  var winY = 0;
  // only set new values if 4.0 browser
  if (parseInt(navigator.appVersion) >= 4) {

    winX = (screen.availWidth - w)*perc*.01;
    winY = (screen.availHeight - h)*perc*.01;
}
  popupWin = window.open(url, name, 'width=' + w + ',height=' + h + ',left=' + winX + ',top=' + winY + ',scrollbars=yes, menubar=yes,resiable=yes');

}

And then you've got popups! Hooray!

Post new comment

The content of this field is kept private and will not be shown publicly.
  • You can use Markdown syntax to format and style the text. Also see Markdown Extra for tables, footnotes, and more.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd> <blockquote> <code> <pre> <embed> <object> <b>
  • Lines and paragraphs break automatically.

More information about formatting options

CAPTCHA
This question is for testing whether you are a human visitor and to prevent automated spam submissions.
Image CAPTCHA
Enter the characters (without spaces) shown in the image.