Add default image for widget
-
I have a problem to show image gd star rating widget. I use image from content with %image% and working properly but i want show a image if the post no content images. I use
function 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 = "/noimage.jpg"; } return $first_img; }
in my theme but I do not integrate into template t2, I also edit render.php in line:
if ($widget["image_from"] == "content") { $row->image = gdFunctionsGDSR::get_first_image($row->post_content); } else if ($widget["image_from"] == "custom") { $row->image = get_post_meta($row->post_id, $widget["image_custom"], true); } else $row->image = "";
But without success.
How I can display a default image if the post no content image?
- The topic ‘Add default image for widget’ is closed to new replies.