[Plugin: Opengraph and Microdata Generator] Select Featured Image
-
the function iafbschema_image() get first image in post to set og:image tag.
In my blog i haven’t image in post but i set it manually in the code. If you want to get featured image instead of first image of the post change the funcion at row 166 of opengraph-microdata.php:function iafbschema_image() { if (has_post_thumbnail( get_the_ID() ) ): $image = wp_get_attachment_image_src( get_post_thumbnail_id( get_the_ID() ), 'single-post-thumbnail' ); $image = $image[0]; else: $Html = get_the_content(); $extrae = '/<img .*src=["\']([^ ^"^\']*)["\']/'; preg_match_all( $extrae , $Html , $matches ); $image = $matches[1][0]; endif; if($image) { $pos = strpos($image, site_url()); if ($pos === false) { return $_SERVER['HTTP_HOST'].$image; } else { return $image; } } else { return get_option('wpogmcthumbnail'); } }http://ww.wp.xz.cn/extend/plugins/opengraph-and-microdata-generator/
The topic ‘[Plugin: Opengraph and Microdata Generator] Select Featured Image’ is closed to new replies.