Download & Extend

Use imagecache preset for large images

Project:jQuery Lightbox
Version:6.x-1.x-dev
Component:Code
Category:feature request
Priority:normal
Assigned:Unassigned
Status:active

Issue Summary

Maybe I'm missing something, but there doesn't seem to be a way to resize the large images. This would be useful when my client decides to upload a huge image.

I can code a patch if that helps, just not really sure where this should go. Maybe its more of a javascript thing, since it should be dependent on browser size.

Comments

#1

Hm, that's certainly out of the scope of jLightbox. However, isn't there a field property for each Imagefield to assign a maximum width and height for all uploaded images of a field? I used that to ensure all images of jLightbox-enabled Imagefields do not exceed a certain size.

#2

Yeah, that's a solution. Do you think being able to set an imagecache preset for the lightboxed image would be a useful feature addition to this module, especially since we're integrating with imagecache in other places like imagefield display?

#3

Currently, this would lead to great confusion and the CCK field settings UI would suffer from this. Let me explain:

In the field settings, you configure in which image size (imagecache preset) an Imagefield image should be displayed, separately for teaser and full view. What we want to alter is not the image size, but the link pointing to the image. Fortunately, Imagecache already provides all presets in two fashions: a pure image of a preset and the same 'as link'.

Imagine we have three presets: thumbnail, preview, original. Foreach of these presets, there are two options for each Imagefield and jLightbox is adding another one:

thumbnail
thumbnail as link
jLightbox thumbnail
preview
preview as link
jLightbox preview
original
original as link
jLightbox original

All we could currently do is to power all presets with different link sizes:

thumbnail
thumbnail as link
jLightbox (thumbnail)
jLightbox (preview)
jLightbox (original)
preview
preview as link
jLightbox (thumbnail)
jLightbox (preview)
jLightbox (original)
original
original as link
jLightbox (thumbnail)
jLightbox (preview)
jLightbox (original)

As you can see, the select boxes would be cluttered with many image display options. If you know a workaround, let me know.

#4

I was actually thinking more along the lines of a global preset for all full-size lightboxed images, since if someone wants to use it for one, the probably would want to use it for all. Something at /admin/settings/jlightbox - "Lightbox imagecache preset", unset by default.

#5

Version:5.x-1.1» 5.x-1.x-dev

Sounds reasonable. Mind to create a patch? :)

#6

Maybe look for a 'jlightbox' preset and use it if you find it.

<?php
/**
* Implementation of theme_imagefield_jlightbox().
*/
function theme_imagefield_jlightbox($namespace, $formatter, $field, $item, $attributes = array()) {
  ...
  ...
 
 
// Defer to a preset called jlightbox (if it exists) for the lightbox image.
 
if (count(imagecache_preset_by_name('jlightbox'))) {
   
$item['filepath'] = file_directory_path() .'/imagecache/jlightbox/'. $item['filepath'];
  }
 
$output = l($image, $item['filepath'], $link_attributes, NULL, NULL, FALSE, TRUE);

  return
$output;
}
?>

#7

Hm. I was about to turn this code into a patch. But then I reconsidered - this would actually make all those additional (existing) ImageField presets/field formatters obsolete, wouldn't it?

#8

I just done a sneaky and hacked a theme hook...

extracts the filepath and passes it back thru imagecache

/**
* Implementation of theme_imagefield_jlightbox().
*/
function mytheme_imagefield_jlightbox($namespace, $formatter, $field, $item, $type, $attributes = array()) {
  $attributes['class'] = 'image '. $namespace;
  $gallery = '';

  $imagecache_path = file_create_url(file_directory_path() .'/imagecache/'. $namespace .'/'. $item['filepath']);
  $image = theme('imagecache', $namespace, $item['filepath'], $item['alt'], $item['title'], $attributes);

  if ($type == 'gallery') {
    $gallery = '['. form_clean_id($field['field_name']) .']';
  }
  $link_attributes = array(
    'rel' => 'lightbox'. $gallery,
    'title' => ($item['alt'] != $item['filename']) ? $item['alt'] : $item['title'],
  );


  preg_match('/(http.*?)"/', theme('imagecache', 'large_image', $item['filepath']), $matches);
  $output = l($image, $matches[1], $link_attributes, NULL, NULL, FALSE, TRUE);

  return $output;
}

#9

Version:5.x-1.x-dev» 6.x-1.x-dev

+1 for this.

Basically, the creation of gallery is great, but it seems to always show the original uploaded image in the lightbox (popup).

To re-iterate: I'd like to show all images on the node page as an imagecache preset (eg. 'thumbnail' is currently possible by using the "jLightbox: thumbnail gallery" formatter) but when clicked, would like to show another imagecache preset instead of the original file.

I think as #3 is trying to say, this would involve multiple choices for each gallery size: the size for those images always shown, in combination with all other sizes, the second to determine the imagecache preset to show in the lightbox (popup).

nobody click here