Hi Maintainers,

I found a little bug in the node_gallery.pages.inc. On an empty gallery I got an php warning invalid arg.. for each for line 290 and 370 on the tabs manage images / sort images tab.

The functions are: node_gallery_edit_images_form and node_gallery_sort_images_form

both functions have an foreach statement that will run without checking if there is an image. So just wrapp it with an if statement.

  //but fid is just an identifier here, so needn't care it.
  // only do this if there is an image
  if (!empty($gallery->images) && is_array($gallery->images)) {
  foreach ($gallery->images as $fid => $f) {
    $options[$fid] = '';
    if ($f->is_cover) {
      $cover_fid = $fid;
    }
  }
  }

And the warning will not show up on empty galleries.

Cheers
Dirk

Comments

dbeall’s picture

Title: Php Warning on empty Galeries » Php Warning on 'Manage Images' page with an empty Gallery
Status: Active » Reviewed & tested by the community
StatusFileSize
new630 bytes

Yep, sure is a bug and this sure did fix it.. Nice Find Dirk !!

Made a patch file from Design Work's code..

dbeall’s picture

hold on a second.. that is just one function.. brb

dbeall’s picture

StatusFileSize
new1.11 KB

duu, here it is with both functions and it actually had 3 errors..
manage images / sort images tab and Galleries list page

dbeall’s picture

StatusFileSize
new1.11 KB

darn.. the + sign was in the wrong place on the second function.. I'm done now..

Thank you Dirk, I have a few other things I don't know how to fix if you want to use your skills..
-- the image caption display in lightbox2 contrib #481420: Image caption not appearing below image in lightbox view This is marked fixed, but it's really half fixed...

I don't know php yet, just started attempting to learn it..

designwork’s picture

Hi dbeall,

yes I will see what I can do to help. I`m trying to integrate some different display options for galleries first. than I have a look at the lightbox problem.

Just one question about the usability.
I have a gallery list, from there i go to a gallery with Thumbnails, from there i go to the image to see it bigger. For me this are to much steps. I expect at the gallery level allready a kind of sildeshow.

Do you think I`m wrong?

Dirk

designwork’s picture

Hi dbeall,

you may have a look here to see what I mean http://photographer.freelens.ws/node/7

Cheers

Dirk

designwork’s picture

Hi dbeall,

I think I found a solution wich is more convinient for the lightbox problem.

As I remember lightbox uses the alt text of the images to display as caption.

So in your function (theme.inc)

function theme_image_view($imagecache, $image) {
  return theme('imagecache', $imagecache, $image->filepath, $image->title, $image->title);
}

you call twice the $image->title as attribute for theme imagecache. Instead of this you should use it like this

function theme_image_view($imagecache, $image) {
 if (!empty($image->body)){
 $alt = $image->body;
 } else {
 $alt = $image->title;
}
  return theme('imagecache', $imagecache, $image->filepath, $alt, $image->title);
}

I had the same problem with my js that I use to display the gallery on the link I gave you.

Cheers

Dirk

kmonty’s picture

Status: Reviewed & tested by the community » Fixed

Great catch. Thanks for the patch DesignWork (and dbeall!)

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

natmchugh’s picture

The best solution I found to this problem is to decalre the return array in function node_gallery_get_gallery_images before use

i.e. add $images = array(); to the top of the function