This script makes a loop showing only posts with images, but I have a problem. It doesnt show the right ammount of posts pr page. Probably because it counts the total nr of posts, including the ones without pictures. Does anyone know how to fix this?
<?php
while ( have_posts() ) : the_post();
$content = $post->post_content;
$searchimages = '~<img [^>]* />~';
preg_match_all( $searchimages, $content, $pics );
$iNumberOfPics = count($pics[0]);
if ( $iNumberOfPics > 0 ) {
//your loop content goes here
}
endwhile;
?>
Second problem: It also shows broken-image if the image in the post is external.