Forum Replies Created

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thanks for your quick response and do credit me in ChangeLog.

    But I think above solution is only a work-around solution for old posts.

    In function ‘Save_post($post_id)’, you should add more source code to update ‘al2fb_facebook_link_picture’ same way as you wrote in function ‘Add_link($post)’.

    Because with new post, you launch function ‘Add_link($post)’ one time, and ‘al2fb_facebook_link_picture’ field has a value.

    With above solution, it’s alway get the data from ‘al2fb_facebook_link_picture’ and it doesn’t care that ‘c_al2fb_meta_image_id’ was changed or not.

    It means with new post, it always use the first chose image when Add_link was launch.

    I turned on option using Open Graph and has same issue.

    I found that function WP_head() alway gets $link_picture from ‘c_al2fb_meta_link_picture’ but the old post has not al2fb_facebook_link_picture (but has ‘c_al2fb_meta_image_id’). So it always gets empty string and uses the default.

    I made a hot fix like that:

    Before:
    // Get link picture
    $link_picture = get_post_meta($post->ID, c_al2fb_meta_link_picture, true);
    if (empty($link_picture)) {
    $picture = get_user_meta($user_ID, c_al2fb_meta_picture_default, true);
    if (empty($picture))
    $picture = self::Redirect_uri() . ‘?al2fb_image=1’;
    }

    After:
    // Get link picture
    $link_picture = get_post_meta($post->ID, c_al2fb_meta_link_picture, true);
    if (empty($link_picture)) {
    $image_id = get_post_meta($post->ID, c_al2fb_meta_image_id, true);
    if (!empty($image_id) && function_exists(‘wp_get_attachment_thumb_url’)) {
    $picture = wp_get_attachment_thumb_url($image_id);
    }
    if (empty($picture)) {
    $picture = get_user_meta($user_ID, c_al2fb_meta_picture_default, true);
    }
    if (empty($picture))
    $picture = self::Redirect_uri() . ‘?al2fb_image=1’;
    }

    And this solution works with me!

Viewing 2 replies - 1 through 2 (of 2 total)