Closed (won't fix)
Project:
Image
Version:
5.x-1.9
Component:
image.module
Priority:
Normal
Category:
Support request
Assigned:
Unassigned
Reporter:
Created:
20 Jul 2008 at 13:42 UTC
Updated:
15 Jan 2009 at 02:38 UTC
I have a static home page, and wanted to place a random image on it. Using PHP Code as my import format, I added the following code to my page to do just this.
$images = image_get_random();
$image=$images[0];
$img_size=IMAGE_PREVIEW;
$info = image_get_info(file_create_path($image->images[$img_size]));
$output = '<div style="width: '. $info['width'] .'px" class="image-attach-body">';
$output .= l(image_display($image, $img_size), "node/$node->iid", array(), NULL, NULL, FALSE, TRUE);
$output .= '</div>'."\n";
echo $output;
The second line onwards are mainly from the function theme_image_attach_body($node) in the image_attach.module (in /image/contrib/image_attach), and, I suspect there is a way to replace these lines with a call to the function, but I couldn't figure it out.
To output the image body text as the caption, use the following (detailed here):
$images = image_get_random();
$image=$images[0];
$img_size=IMAGE_PREVIEW;
$info = image_get_info(file_create_path($image->images[$img_size]));
$caption = node_teaser($image->body);
$output = '<div style="border-bottom:1px solid #999999;margin-left:30px; float:right;width: '. $info['width'] .'px" class="image-attach-body">';
$output .= l(image_display($image, $img_size), "node/$node->iid", array(), NULL, NULL, FALSE, TRUE);
$output .= '<div class="caption">' . $caption . '</div>';
$output .= '</div>'."\n";
echo $output;
Comments
Comment #1
sunSorry, unfortunately this request is way too specific. Please have a look at the issue queue - Image maintainers are buried already. You might want to try to get further support at http://drupal.org/support. Additionally, the answer to your question might be covered in the handbooks at http://drupal.org/handbook/modules/image already.
If you were able to solve this issue on your own in the meantime, you might want to add the involved steps to this closed issue, so other users searching for a similar solution might find it.