WordPress.org

Ready to get started?Download WordPress

Forums

Facebook
og:image missing (4 posts)

  1. Mark
    Member
    Posted 1 year ago #

    I was previously using an open graph plugin that had an algorithm for picking the image to send to Facebook in open graph. It looked first to see if there was a featured image for the post/page, then if not to see if there were any images in the post/page itself, and if not it then it fell back to a default image specified in the settings.

    The Facebook plugin is (at least for me) not consistent in this regards. For posts, I'm not sure if it's picking the first image or the featured image (for me they are usually the same, but it is at least passing an image. For pages however, there's no image value being passed. I see this both from looking at the resulting code as well as the debugger. Here's a page from my site as an example, when I run it through the debugger it points out the image is missing. Is there a setting somewhere that controls this or does the plug-in not look for images on pages?

    If not, could a future iteration be updated to A) Include images on pages and B) allow us to set a default image for those instances when a page or post lacks any images?

    Note, I've hard-coded the like button into my template, but even when I disable and turn on the Facebook plug-in like button, I still see the same behavior. It's the halfway problem I can't get around easily. I could tell WordPress what og:image to pass but on posts it would be duplicated.

    http://wordpress.org/extend/plugins/facebook/

  2. Niall Kennedy
    Member
    Plugin Author

    Posted 1 year ago #

    The Facebook plugin outputs og:image values if a post type supports featured thumbnails and a featured thumbnail exists for the post.

    You can add your own default image by tapping into the fb_meta_tags filter.

  3. Mark
    Member
    Posted 1 year ago #

    So it appears only posts thumbnails are supported? Is there a reason pages are not supported? As I said, the previous plugin I was using was able to accomplish both tasks.

    I'll look at your link, and see if it's something I can manage on my own in the interim but I don't think it's expecting much for Facebook's own plugin to handle both Page and Post featured images. Joe User (and I likely fall into that camp myself) isn't expecting to have to jump through hoops. Heck, how many posts have I read just for the support issues in this plugin that involved users unsure how to even FTP into their site?

    At any rate, thanks for the confirmation and for the link! I'll see what I can make of it.

  4. Gaerwn
    Member
    Posted 1 year ago #

    Change in file /wp-content/plugins/facebook/fb-open-graph.php, this code (line 150):

    else if ( is_page() ) {
    $meta_tags['http://ogp.me/ns#type'] = 'article';
    $meta_tags['http://ogp.me/ns#title'] = get_the_title();
    $meta_tags['http://ogp.me/ns#url'] = apply_filters( 'rel_canonical', get_permalink() );
    }

    with this one

    else if ( is_page() ) {
    $meta_tags['http://ogp.me/ns#type'] = 'article';
    $meta_tags['http://ogp.me/ns#title'] = get_the_title();
    $meta_tags['http://ogp.me/ns#url'] = apply_filters( 'rel_canonical', get_permalink() );
    // page thumbnail
    if ( function_exists( 'has_post_thumbnail' ) && has_post_thumbnail() ) {
    list( $post_thumbnail_url, $post_thumbnail_width, $post_thumbnail_height ) = wp_get_attachment_image_src( get_post_thumbnail_id( $page->ID ), 'full' );
    if ( ! empty( $post_thumbnail_url ) ) {
    $image = array( 'url' => $post_thumbnail_url );
    if ( ! empty( $post_thumbnail_width ) )
    $image['width'] = absint( $post_thumbnail_width );
    if ( ! empty($post_thumbnail_height) )
    $image['height'] = absint( $post_thumbnail_height );
    $meta_tags['http://ogp.me/ns#image'] = array( $image );
    }
    }
    }

    It worked for me.

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic