Yes it is possible, and not all that difficult. You upload the images when creating the post.
Then in single.php you use get_children to get all images from the post.
assuming in the loop:
$images =& get_children( 'post_type=attachment&post_mime_type=image&post_parent=$post->ID' );
and output them like so:
if ($images)
{
foreach ( $images as $attachment_id => $attachment ) {
echo wp_get_attachment_image( $attachment_id, 'full' );
}
}
For your random image you could either use the same get_children as above but add &numberposts=1
to the args string.
or something like:
function fetch_random_img($postid='') {
global $wpdb;
if (empty($postid))
{
//we are going for random post and random image
$postid = $wpdb->get_var("SELECT ID FROM $wpdb->posts WHERE post_status = 'publish' ORDER BY RAND() LIMIT 1");
}
$imageid = $wpdb->get_var($wpdb->prepare("SELECT ID FROM wp_posts WHERE post_type='attachment' AND post_mime_type LIKE 'image/%' AND post_parent=$postid ORDER BY RAND() LIMIT 1"));
if ($imageid) {
echo wp_get_attachment_image( $imageid, 'full' );
}
else {
return false;
}
}
This will give you only one random image, and it will be random, whereas get_children will pull out the same image each time unless you add order and orderby arguments, which will allow you to change which image comes out.
To echo the image within a div just call the function:
<div>
<?php fetch_random_img(); ?>
</div>