Hi. This module is very nice! I like it.
I have a offer that this module supports handling empty imagefields.
I need this functionality, so I HACK the code. My HACK is below.
function theme_jquery_slideshow_formatter($element) {
static $rendered;
if (!$rendered) {
$rendered = TRUE;
$nid = $element['#item']['nid'];
$node = node_load($element['#item']['nid']);
$field_name = $element['#field_name'];
if($node->{$field_name}){
$jq_slideshow_id = 'jq-slideshow-'. $nid .'-'. $field_name;
# render CSS files
$formatter = $element['#formatter'];
$dets = explode('__', $formatter);
$preset = $dets[1];
_jquery_slideshow_get_settings($jq_slideshow_id, $preset);
# render output HTML
$output = '<div class="jquery_slideshow" id="'. $jq_slideshow_id .'">';
foreach ($node->{$field_name} as $image) {
if($image){
$output .= theme('imagecache', $preset, $image['filepath'], $image['data']['alt'], $image['data']['title']);
}
}
$output .= '</div>';
}
}
return $output;
}
If possible, I want next version of Jquery_slideshow to include this codes.
I'm sorry for my poor English.
Thank you.
Comments
Comment #1
ptaro commentedComment #2
nvoyageur commentedCan you provide a diff file? It's easier to identify your changes....
Thanks,
Shane
Comment #3
ptaro commentedI'm sorry for my late reply !
Here is a diff file.
Thank you.
Comment #4
nateb commentedThis is appreciated. Certainly helpful.
Comment #5
nvoyageur commentedComment #6
tobedeleted commentedWill this be rolled in to an official release any time soon?
Comment #7
nvoyageur commentedWhen I release the next version of the module I'll try to incorporate these changes. It looks like there is some interest in this functionality although it still baffles me why you would have blank imagefields.
Comment #8
Arban commentedsubscribe
Comment #9
mcurry commentedsubscribe
@nvoyager:
I'm not sure if we're talking about the same things here, but in my case, I have a content type with an image field that allows up to three images uploaded. If the user uploads less than three (perfectly valid choice, the imagefield module allows it), then there are 'blank' image fields in the database, and the slide show displays a 'broken image' in the place of the 'empty' imagefields, which makes the slide show look a bit strange.
So it's not that I want a blank image field, it's that the user has the option to not upload every possible image. In that case, the slide show should not try to display the 'empty' imagefields (and it does, at least on my install). Not sure if this is a problem with imagefield or the slide show module; I'm not yet up on how CCK/imagefield does its thing.
I did notice that this wasn't a problem on my 5.x installation with the same set-up (CCK, ImageField, JQuery Slideshow)
edit: I just applied the OP's patch and it seems to fix the problem I described. Everything is working just fine now.
Comment #10
mcurry commentedI'm changing this to a bug report since a valid imagefield configuration seems to trigger incorrect behavior. (See my prior post for details.)
Comment #11
nvoyageur commentedThe latest version 2.x-dev should support blank/missing images. Please test this out.
Comment #12
mradcliffeI tested this out tonight with the 2.x development branch, but it is still loading imagefield that does not contain any data.
Comment #13
imclean commentedVery handy module, thanks! I also needed to support an empty imagefield. This is simply so the field can be left empty if required. The client can then add 1 or more images if they so choose, or if the content layout needs more room the images can be removed.
In my case, using the current dev version only the js required modification. It now checks that there actually is an id before processing.
Comment #14
mcurry commentedI downloaded the 6.x-2 version from github:
http://github.com/nvoyageur/Jquery-Slideshow/downloads
And the problem persists, even if I apply imclean's patch @ comment #13.
What is the correct version of Jquery Slideshow for Drupal 6?
Comment #15
mcurry commentedAh, I see the problem now. The formatter code needs to supress all divs if the image is null:
Here's a diff against the 6.x-2.x-dev build taken from drupal.org (https://drupal.org/node/688166) -- note the location of the
if ($image) {logic:Of course, this mod breaks the "n of nn" display, since the count is wrong now -- the simple fix requires that the count is calculated ahead of time based on similar logic. I'll work on a fix for that and submit a proper patch.
Comment #16
kevinquillen commentedI had an issue where if a node does not have any images, jquery slideshow still tries to do stuff, which broke the whole page.
Here is my quick fix around that issue:
If there was at least 1 image then it will add the js and css and return the output. Otherwise it won't do anything, and my page was fine. There is probably a more efficient way to do this, but I needed to fix this fast on a live site.