unction insert_image_src_rel_in_head() { 02 global $post; 03 if ( !is_singular()) //if it is not a post or a page 04 return; 05 if(!has_post_thumbnail( $post->ID )) { //the post does not have featured image, use a default image 06 $default_image="http://example.com/image.jpg"; //replace this with a default image on your server or an image in your media library 07 echo ''; 08 } 09 else{ 10 $thumbnail_src = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), 'medium' ); 11 echo ''; 12 } 13 echo " 14 "; 15 } 16 add_action( 'wp_head', 'insert_image_src_rel_in_head', 5 );