<?php $id =$post->ID;
$the_content =$wpdb->get_var("SELECT post_content FROM $wpdb->posts WHERE ID = $id");
$pattern = '!<img.*?src="(.*?)"!';
preg_match_all($pattern, $the_content, $matches);
$image_src = $matches['1'][0];?>şöyle bir php kodum var. bu kod ile konu içerisinde resim varsa <?php echo $image_src; ?>diye ekrana bastırıyorum.
fakat resim olmadığı vakit boş dönüyor. bunu engellemek için boş bi resim oluşturdum ve link verdim
http://siteadi.com/resimyok.jpg şeklinde
<?php if(!$image_src) {
echo ''.$image_src.'&w=140&h=100&zc=1';
}else {
echo 'http://www.siteadi.com/resimyok.jpg';
}
?>bu şekilde kullandığımda tüm değerleri elseye yani resimyok.jpg ye atıyor. bunu nasıl çözerim?içerikte resim varsa göstersin. yoksa boş resmi göstersin.