I'm using lightbox 2, imagecache and default image option in cck imagefield. Everything works perfectly until i try to show default image, if user doesn't post his, in created preview (views). I managed somehow to avoid "broken link" picture, but now it show only empty space. I'm using table view with multiple nodes, each of them can have 2 pictures. It's easier to explain if i show you picture :) Thank you for this module.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

baja_tz’s picture

Sorry but this might be issue for imagefield?

stella’s picture

I'd need to see the page source in order to know what's happening. Is this a public site?

You mention it may be an issue with the imagefield module - does it work if you disable the lightbox module?

Cheers,
Stella

baja_tz’s picture

I didn't disable lightbox but I tried other options for image in my view (default, thumbnail...) without using lightbox and it doesn't work.
When viewing full node it works with lightbox, so i suppose it's not lightbox. Btw. I had to change some code to avoid broken link image when using default image, if you want to see this, it might be usefull for you: http://drupal.org/node/180592#comment-650042 and http://drupal.org/node/198311. Thank's for your answer.
Cheers,
Sasa

stella’s picture

Assigned: Unassigned » stella
FileSize
1.62 KB

Hi,

I've created a similar patch to the provided at #198311. Please use the attached patch or the latest dev release (should be available later today). If this doesn't resolve the issue, then I will need to see the page source.

Cheers,
Stella

baja_tz’s picture

It doesn't. I think that you made some typos in your patch. It should be:
return theme('imagefield_image_imagecache_lightbox2', $namespace, $field, $item);
not
return theme('imagefield_image_imagecache_lightbox2', $namespace, $field, $filepath, $item, $item['alt'], $item['title']);
there is not point to pass $filepath value to your theme because $filepath variable is not set in theme declaration.
function theme_imagefield_image_imagecache_lightbox2($namespace, $field, $item, $attributes = NULL).
With excluded (commented) $item = array_merge($item, $file); there is no "Text for Node Link" on the bottom of the image. On live site i'm using "v 1.16.2.17.2.17" but i tried newer versions on my localhost and there is no differencies except some minor issues i didn't like so i choosed older version. anyway this is what i've done:

function lightbox2_field_formatter($field, $item, $formatter) {
  if (module_exists('imagefield') && module_exists('imagecache')) {
  	if (isset($item['filepath'])) {
 	$filepath = &$item['filepath']; 
    } else if (!empty($item['fid'])) {
      $file = _imagefield_file_load($item['fid']);
      $filepath = &$file['filepath'];
    } else { 
      return '';
    }
    if (lightbox2_exclude_these_paths() != 1) {
      lightbox2_add_files();
    }
    $item = array_merge($item, $file);
    if (strpos($formatter, 'lightbox2][') !== false) {
      list($null, $namespace) = explode('][', $formatter, 2);
      $rules = _imagecache_get_presets();
      if (in_array($namespace, (array) $rules)) {
  
        return theme('imagefield_image_imagecache_lightbox2', $namespace, $field, $item, $filepath); 
      }
    }
  }
}

function theme_imagefield_image_imagecache_lightbox2($namespace, $field, $item, $filepath, $attributes = NULL) {
  $imagecache_path = file_create_url(file_directory_path() .'/imagecache/'. $namespace .'/'. $filepath); 
  $rel = 'lightbox';
  if (variable_get('lightbox2_image_group', TRUE)) {
    $rel = 'lightbox[cck_image_nodes]';
  }
  
  $node_link = '';
  if (!empty($item['nid'])) {
    $node_link = '<br /><br />'. l(t(variable_get('lightbox2_node_link_text', 'View Image Details')), 'node/'. $item['nid']);
  }
  
  $link_attributes = array(
    'rel' => $rel,
    'title' => $item['alt'] . $node_link);

 $image = theme('imagecache', $namespace, $filepath, $item['alt'], $item['title'], $attributes); 
 $output = l($image, file_create_url($filepath), $link_attributes, NULL, NULL, FALSE, TRUE); // ja dodao 
  return $output;
}
 

There is no differencies even if i don't change theme function but i did it because i think it will be important once when this issue with imagefield will be solved. I installed thickbox to check how it works and everything is same. For further explanation please check isuue that i've posted on imagefield: http://drupal.org/node/199647.
I'll sent you address and login for site to check page source. Thank you for your patience.

stella’s picture

Status: Active » Needs review
FileSize
1.13 KB

Attached is a fixed version of the patch.

baja_tz’s picture

There is no "Text for Node Link (view image details)" on the bottom of the image without $item = array_merge($item, $file);
I put
$item = array_merge($item, (array)$file);
and it works without throwing error "array_merge() [function.array-merge]: Argument #2 is not an array in..." when using lightbox2 for images in full node preview.

stella’s picture

FileSize
1.17 KB

Would you mind trying out the attached patch? Thanks for helping me test this.

Cheers,
Stella

baja_tz’s picture

I already have that so i can tell you that it works...for now :) I've sent you address and login on my site via your contact so if you want to see ... but i'm sure it's imagefield issue. I can't get that default image on my view, as I said when viewing full node it works with imagecache and lightbox now.

stella’s picture

Status: Needs review » Fixed
stella’s picture

Released in Lightbox V2 5.x-2.2.

Cheers,
Stella

Anonymous’s picture

Status: Fixed » Closed (fixed)

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