Right now the standard behavior is that if there are no images in a post, just an empty grey background appears on the main index page above the post title and excerpt. If the post has images, the LAST image is cropped down and appears within the grey background on main index page. If I'm reading the function correctly in functions.php, it's actually parsing through ALL the images in the post and putting them on the main index page, with the last one staying. Seems a bit like extra work and not the behavior I want anyway.
The current function being called is:
# Displays post image attachment (sizes: thumbnail, medium, full)
function dp_attachment_image($postid=0, $size='thumbnail', $attributes='') {
if ($postid<1) $postid = get_the_ID();
if ($images = get_children(array(
'post_parent' => $postid,
'post_type' => 'attachment',
'numberposts' => 1,
'post_mime_type' => 'image',)))
foreach($images as $image) {
$attachment=wp_get_attachment_image_src($image->ID, $size);
?><img src="<?php echo $attachment[0]; ?>" <?php echo $attributes; ?> /><?php
}
}
What I'd like to have happen is if there are images in a post, the first image is always the one that shows up on the main index page. If there are no images associated with the post, I have a default image I want to have appear instead.
I'm hacking around at this but not sure what I'm doing (other than occasionally having a syntax error that crashes the site :) ) so any help is appreciated.