Support » Plugins and Hacks » Yoast SEO » [Plugin: WordPress SEO by Yoast] Default image for Open Graph breaks when Facebook plugin activated

  • Hi,

    In the latest version of WordPress SEO plugin, I see Yoast uses a filter fb_meta_tags to change the open graph meta tags. It works nicely, except one thing: the default image set in the plugin settings page doesn’t work, because Facebook will get only the thumbnail image.

    I made a quick fix for this, and applied in one of my site, it’s working. Here it is:

    add_filter( 'fb_meta_tags', 'bc_fb_image' );
    
    /**
     * Add default image open graph meta when both Facebook & WordPress SEO plugins activated
     *
     * @param array $meta_tags
     *
     * @return array
     */
    function bc_fb_image( $meta_tags )
    {
    	if ( !empty( $meta_tags['http://ogp.me/ns#image'] ) )
    		return $meta_tags;
    
    	$wpseo_option = get_option( 'wpseo_social' );
    
    	if ( empty( $wpseo_option['og_default_image'] ) )
    		return $meta_tags;
    
    	$image = array( 'url' => $wpseo_option['og_default_image'] );
    
    	$meta_tags['http://ogp.me/ns#image'] = array( $image );
    
    	return $meta_tags;
    }

    I hope Yoast can include this feature in the next version of the plugin, because I see the WordPress SEO has more options for OG image (featured image, first image in the content, and the default image) than the Facebook plugin.

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

Viewing 4 replies - 1 through 4 (of 4 total)
Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘[Plugin: WordPress SEO by Yoast] Default image for Open Graph breaks when Facebook plugin activated’ is closed to new replies.