IMG tag building for no featured image
-
Some themes like “WP FanZone” shows featured images in blog top page.
When a post does not have a featured image, Multisite Featured Image writes the src attribute with no value.
This causes layout problem.I fixed below:
function ibenic_mufimg_post_thumbnail_html($html, $post_id, $post_thumbnail_id, $size, $attr) { /*snip*/ $imgTag = ''; // initialize if ($imgURL != '') { // do not write tag if $imgURL is not available $imgTag = "<img "; $imgTag .= " src='".esc_url( $imgURL )."' "; if(is_array($attr) && count($attr) > 0){ foreach ($attr as $attribute => $value) { $imgTag .= " ".$attribute."='".$value."' "; } } $imgTag .= " />"; } // end if return $imgTag; }
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
- The topic ‘IMG tag building for no featured image’ is closed to new replies.