WordPress.org

Ready to get started?Download WordPress

Forums

WordPress SEO by Yoast
Using Featured Image's Thumbnail for Facebook's og:image (12 posts)

  1. Baden
    Member
    Posted 1 year ago #

    WordPress version: 3.4.2
    WordPress SEO version: 4.2.7

    I did this: Assigned a Featured Image to a post

    I expected the plugin to do this: Use 'Thumbnail' of the Featured Image as the og:image value (Default: 150 x 150 Cropped, changed to 200 x 200 Cropped)

    Instead it did this: Used 'Medium' of the Featured Image (300 x 300, not cropped).

    Now that that's out of the way.
    By default, this plugin will use the Medium version of a post's featured image. This is fine, but there is no option to tell it to use a) thumbnail (that can be set in Settings > Media) or b) a custom image size set up in the theme's functions.php file. This would be a nice addition for a future release. In the meantime, to manually change to using 'thumbnail' or 'my-custom-facebook-thumbnail' sizes:

    Adjust 'medium' to the desired thumbnail size on line 155 of class-opengraph.php found under:
    frontend > class-opengraph.php

    From:

    $featured_img = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), apply_filters( 'wpseo_opengraph_image_size', 'medium' ) );

    To:

    $featured_img = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), apply_filters( 'wpseo_opengraph_image_size', 'thumbnail' ) );

    That is all.

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

  2. Ryan Burnette
    Member
    Posted 1 year ago #

    You just add a filter to your functions file to fix this rather than editing the plugin. Here's the code I'm using.

    // Tell WP SEO to use a larger thumbnail
    function sc_opengraph_image_size($size="medium") {
    	return "full";
    }
    add_filter('wpseo_opengraph_image_size','sc_opengraph_image_size',10,1);
  3. Baden
    Member
    Posted 1 year ago #

    Yup, that's way better.

  4. Ryan Burnette
    Member
    Posted 1 year ago #

    I've had a lot of issues with this. The fact that apply_filters is used in the plugin makes me assume Yoast plans to make this a setting. He really should because I'm having to fix this way too often.

  5. boborg
    Member
    Posted 1 year ago #

    I set the featured image 300x300 and then insert a thumbnail 150x150 of the same into the post.

    With WordPress Seo Social turned on I then get 2 meta property='og:image' entries. First the featured image and then the thumbnail 150x150.

    Including the function // Tell WP SEO to use a larger thumbnail there are still 2 og:image entries. Only difference is the file name has the 300x300 included in the filename without the function file fix.

    So is this how it is supposed to work?

  6. Ryan Burnette
    Member
    Posted 1 year ago #

    This post I made a while back includes some code that should fix it for you if you have a big enough image to work with. http://wordpress.org/support/topic/plugin-wordpress-seo-by-yoast-using-featured-images-thumbnail-for-facebooks-ogimage?replies=5#post-3607484

  7. Claude Vedovini
    Member
    Posted 1 year ago #

    the question I have is why not using the full picture as a default, Facebook is recommending 1500x1500 for those images now...

  8. Night Hawk
    Member
    Posted 1 year ago #

    I was looking all the net about this flaw, why the plugin show red dot when I only post with featured image? Thats mean Google not see my image too?

  9. r1se
    Member
    Posted 1 year ago #

    Thanks a lot ryan! It works awesome.

  10. Mikael Korpela
    Member
    Posted 1 year ago #

    FB is currently changing their requirements for news feed images. I'd suggest to change default behaviour accordingly.

    https://developers.facebook.com/blog/post/2013/04/03/platform-updates--operation-developer-love/

    Minimum is 200x200 (so ppl don't use thumbnail size!) and recommendation 600x600, so default "medium" 300x300 is a bit too small.

    I'd use "full" as default.

  11. Ryan Burnette
    Member
    Posted 1 year ago #

    I've started declaring a custom thumbnail size for this and using the filter method I mention in my previous comment,

    Perhaps Joost will address this in a future version. At least he put the filter there which helps us deal with this for now.

  12. kmieta
    Member
    Posted 1 year ago #

    Hi,

    i've set thumbnail size to 300x300 and i change line 254 in frontend > class-opengraph.php:

    from

    $thumb = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), apply_filters( 'wpseo_opengraph_image_size', 'large' ) );

    to

    $thumb = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), apply_filters( 'wpseo_opengraph_image_size', 'thumbnail' ) );

    unfortunately it's does't work...

    where i must add function:

    // Tell WP SEO to use a larger thumbnail
    function sc_opengraph_image_size($size="medium") {
    	return "full";
    }
    add_filter('wpseo_opengraph_image_size','sc_opengraph_image_size',10,1);

    ?

    I have WP 3.5.1, and WordPress SEO 1.4.7

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic