First Image From Post & BFI Thumbs?
-
Featured image shows up fine in blog listings, but gray image is shown instead of first image from post – http://monkeyzbusiness.com/
Thoughts?
Functions.php
function get_first_img() { #echo "get first image"; global $post, $posts; $first_img = ''; ob_start(); ob_end_clean(); $output = preg_match_all('/<img.+src=[\'"]([^\'"]+)[\'"].*>/i', $post->post_content, $matches); $first_img = $matches [1] [0]; /* if(empty($first_img)){ //Defines a default image $first_img = "/images/default.jpg"; } */ #echo $first_img; return $first_img; }get_first_img() is grabbing the correct image url. I echoed it to make sure.
loop.php
<?php #if featured image is not set, use first image in the post. #if(get_first_img() ){ echo '.'; } if ( has_post_thumbnail() || get_first_img() )// check if the post has a Post Thumbnail assigned to it. { #echo "has_post_thumbnail() | get_first_img()"; echo '<div class="blog_img ">'; echo '<a href="'.get_permalink().'">'; if( (get_post_meta( $post->ID, 'kaya_image_streatch', true )) == "0") { $params = array('width' => '1100', 'height' => '450', 'crop' => true); } else { $params = array('width' => '', 'height' => '', 'crop' => true); } if(!$img_url=wp_get_attachment_url( get_post_thumbnail_id() )) { $img_url=get_first_img(); } #Test #echo $img_url; echo kaya_imageresize($img_url,$params,''); echo '</a>'; ?> </div> <?php } ?>Thoughts?
Thanks!
The topic ‘First Image From Post & BFI Thumbs?’ is closed to new replies.