Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • #10498

    Hello,

    I want to set an own article picture for facebook, even when there’s no featured media on the top of the page (for example with the standard article picture function, which is deactivated in Brightbox).

    I’ve already read this post:

    http://www.kriesi.at/support/topic/facebook-open-graph-protocol

    but it doesn’t really help me.

    thanks

    #68281

    I have this code, which always worked for me with the standard article image.

    $thumb = get_post_meta($post->ID,’_thumbnail_id’,false);

    $thumb = wp_get_attachment_image_src($thumb[0], false);

    if ($thumb[0] == “”){

    $thumb[0] = “http://…/image.jpg”;

    }

    How can I modify it that it works with the new theme.

    I know that I have to use “$slides[0]” but I don’t know if I just have to replace $thumb[0] or every $thumb etc. I’m not very good in php.

    Please help

    #68282

    Hey!

    to get the post thumbnail in brightbox you can use the following code snippet:


    $image = "";
    $slides = avia_post_meta(get_the_ID(), 'slideshow', true);

    if( $slides != "" && !empty( $slides[0] ) )
    {
    $image = avia_image_by_id($slides[0], 'widget', 'image');
    }

    #68283

    It does recognize the photo if a user clicks on the send button or the like button

    BUT

    If I post the URL in facebook, it doesn’t recognize a photo.

    Try it for example with

    http://treibhaus.co/opening

    The facebook debugger says

    Object at URL ‘http://treibhaus.co/opening/’ of type ‘website’ is invalid because the given value ‘<img src=’ for property ‘og:image:url’ could not be parsed as type ‘url’.

    #68284

    Kriesis code above will return the image with html tag, alt text, etc. and not the image url. Try following code instead:

    $image = "";
    $slides = avia_post_meta(get_the_ID(), 'slideshow', true);

    if( $slides != "" && !empty( $slides[0]['slideshow_image'] ) )
    {
    $image = avia_image_by_id($slides[0]['slideshow_image'], 'widget', 'url');
    }

    #68285

    hmm… very strange

    The debugger doesn’t show errors anymore and there’s the right url in og:image, for example:

    <meta property=”og:image” content=”http://treibhaus.co/wp-content/uploads/2012/02/header1-48×48.jpg” />

    But facebook doesn’t recognize the image when we type the URL in Facebook but it works if we press the send or like button in the article.

    On all other blogs, where we also use kriesi templates, it works (but all the other blogs have the standard article picture)

    Please help

    #68286

    But I think this is more a facebook issue now because we can’t control which content is used by Facebook. If it works with the send or like button the og meta property seems to submit the correct content. I see no reason why Facebook can use it if you click on the button but then (on the other hand) it’s ignored when it fetches the content automatically based on the website url…

Viewing 7 posts - 1 through 7 (of 7 total)

The topic ‘Set an own article picture for facebook’ is closed to new replies.