I want to seperate the image in a post from the rest of the text. When you click on the image it should open the full sixe image in the lightbox (so have "rel=lightbox" in the code). I've used Advanced Excerpt to strip out the text and have the following to call the image:
<?php
function single_med_image($postid=0, $size='medium', $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) {
$fullsize='full';
$attachment=wp_get_attachment_image_src($image->ID, $size);
$linkattachment=wp_get_attachment_image_src($image->ID, $fullsize);?>
<a href="<?php echo $linkattachment[0];?>" rel="lightbox"><img src="<?php echo $attachment[0]?>"></a>
<?php }
}
?>
This is where is gets tricky... I am also attaching images to the post through custom fields (NKMImageField plugin) and this function is calling those instead of the one that I attach in the post. But what I want is the one that would appear when I use a straight forward the_content() . Any ideas?