Quantcast
Channel: WordPress.org Forums
Viewing all articles
Browse latest Browse all 46187

ChillZZ on "[Plugin: WordPress SEO by Yoast] Featured Image set from NextGen Gallery does not show up as opengra"

$
0
0

First of : Joost thanx for this kickarse plugin!

This might be a problem of NextGen Gallery (v1.9.3), I've read problems with featured images set via NGG before, but so far did not encounter any. When using Wordpress SEO to fill all the opengraph entities everything -except the image- works well.

After some testing I found out that wp_get_attachment_image_src : seems to give empty results for an image set via NGG, while it does work for featured images set via the WordPress media gallery.

reading http://yoast.com/facebook-open-graph-protocol/ gave me the idea to replace

// Grab the featured image
		if ( is_singular() ) {
			if ( empty( $image ) && function_exists('has_post_thumbnail') && has_post_thumbnail( $post->ID ) ) {
				$thumbnail = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), 'thumbnail' );
				if ( $thumbnail )
					$image = $thumbnail[0];

with this

// Grab the featured image
		if ( is_singular() ) {
			if ( empty( $image ) && function_exists('has_post_thumbnail') && has_post_thumbnail( $post->ID ) ) {
				$attributes = array('class'	=> "",'alt'	=> "", 'title' => "");
				$fbimage = '';
				$output = preg_match_all('/<img.+src=[\'"]([^\'"]+)[\'"].*>/i', get_the_post_thumbnail($post->ID, 'thumbnail' , $attributes) , $matches);
				$fbimage = $matches [1] [0];
				$image = $fbimage;

in the class-opengraph.php found in \wordpress-seo\frontend\class
and it worked! However this might change functionality for featured images set via the WordPress media gallery (not tested yet) and will break with a new update for WordPress SEO.

Is there a better way to have WordPress SEO to play nice with featured images from NextGen Gallery ?

http://wordpress.org/extend/plugins/wordpress-seo/


Viewing all articles
Browse latest Browse all 46187

Latest Images

Trending Articles



Latest Images