Active
Project:
Node Images
Version:
5.x-1.x-dev
Component:
Code
Priority:
Normal
Category:
Support request
Assigned:
Unassigned
Reporter:
Created:
29 Jan 2008 at 10:47 UTC
Updated:
29 Jan 2008 at 10:47 UTC
Hi, I got this code from the rlisting.module, which enables node images to work with thickbox.module.
To get it working patch (replace) the nodeimage.module file from line 179 to 216 with the following code:
line:178
/// node_image hack
// rewrite the node to include the thickbox class
$view = ($teaser ? 'teaser' : 'body');
$count = variable_get('node_images_'.$view.'_images_'.$node->type, 2);
if (!$format) {
$format = variable_get('node_images_'.$view.'_format_'.$node->type, 'thumbs');
}
$images = "";
foreach((array)$node->node_images as $id=>$image){
$description = check_plain($image->description);
$pattern = '<img src="%path" alt="%description" />';
$thumb = strtr($pattern, array('%path'=>file_create_url($image->thumbpath), '%description'=>$description));
$fullsize = strtr($pattern, array('%path'=>file_create_url($image->filepath), '%description'=>$description));
if (file_exists($image->filepath)){
if ($info = getimagesize($image->filepath)){
$width = $info[0] + 36;
$height = $info[1] + 36;
}else{
$width = 420;
$height = 315;
};
};
if ($format == 'thumbs'){
$images .= '<a class="thickbox" rel="'.$node->nid.'" href="'.$image->filepath.'" title="'.$description.'" height="'.$height.'" width="'.$width.'">'.$thumb.'</a>';
}else{
$images .= $fullsize.' ';
};
if ($count>0 && ++$i >= $count) break;
};
$node->content['node_images'] = array(
'#value' => "<div class=\"node_images\">
$images</div>",
'#weight' => -1,
);
return $node;
}
}
The only bug is it does not work when clean url are enabled. (well the teaser view works, but node view has a bug in the url, placing a node/ before the link, making it invalid.
Thanks and have fun