Viewing 15 replies - 1 through 15 (of 16 total)
  • Plugin Author JS Morisset

    (@jsmoriss)

    This FAQ may help explain Facebook’s behavior: http://surniaulula.com/codex/plugins/nextgen-facebook/faq/why-does-facebook-show-the-wrong-image-text/

    If you have a URL to that post/page, I can also double-check.

    js.

    Thread Starter marciano1

    (@marciano1)

    Permailink changed.
    Thanks.

    Hello, I think that there’s an issue if the image is at the bottom of the post content instead of the top… are you sure you tested it properly? Do You take any image, even if at the bottom and the top is text only? thanks

    understood the issue… you stop at the very first image and check if has the correct size. If not, you use the default image (if set by the user) Wrong. (’cause may be more images, sometimes the first image may be not so big, could be a little logo or such like that, could be a hidden image to display, a hidden image by jQuery… could be many things..)

    EVEN IF the user chooses one image only, (“Max Images to Include”), You have to do a cycle until you find an image with the size greater than that set by the user.

    eg. the user wants one image only and sets a 200×200 size (the minimum accepted on Facebook). You do an array searching for the images contained into the post until you find an image greater (or equal) than 200×200.

    THEN, and only then, if the good image is not found, you insert the default image and so on…

    hope this helps

    Thread Starter marciano1

    (@marciano1)

    It was what JS explained.
    Posts are very simple: an embedded youtube video and three lines of text.
    So I always have to upload a featured image for social shares.
    Sometimes a single image with text is posted, so “first image in post” option is selected (by default) to use as featured image.
    Thanks

    another issue,
    even if I set 2 images…

    the image at the bottom is not taken anyhow…
    so it’s definitely a bug

    How you get the width/height of the image?
    If you search for the tags width height in html is wrong, you have to code in php something like getimagesize(“$url”); and then you have width in $size[0] and height in $size [1]

    ATM your code finds

    <img alt="something.jpg" src="http://www.example.com/images/something.jpg" width="510" height="307" />

    but doesn’t find something like

    <img class="video_overlay" src="http://example.com/static/images/overlay/video_overlay.png"/><img class="video_image" src="http://images.example.com/thumbs/images/2015/06/25/38085-something.jpg" alt="something"/>

    that’s the only reason, it means that you search for width=”xxx” height=”xxx” in the html source. I’m reading your code, what do you mean as attachment or post thumbnail? You should remember that the user can insert into the post even external images on remote sites…and it’s not good if you don’t display them just for this reason.

    you should use the getimagesize() or something like that, instead.
    thanks for your attention
    kind regards

    public function get_size_info( $size_name = 'thumbnail' ) {
    if ( is_integer( $size_name ) )
    return;
    if ( is_array( $size_name ) )
    return;
    global $_wp_additional_image_sizes;
    if ( isset( $_wp_additional_image_sizes[$size_name]['width'] ) )
    $width = intval( $_wp_additional_image_sizes[$size_name]['width'] );
    else $width = get_option( $size_name.'_size_w' );
    if ( isset( $_wp_additional_image_sizes[$size_name]['height'] ) )
    $height = intval( $_wp_additional_image_sizes[$size_name]['height'] );
    else $height = get_option( $size_name.'_size_h' );
    
    if ( isset( $_wp_additional_image_sizes[$size_name]['crop'] ) )
    $crop = $_wp_additional_image_sizes[$size_name]['crop'];
    else $crop = get_option( $size_name.'_crop' );
    if ( ! is_array( $crop ) )
    $crop = empty( $crop ) ? false : true;
    return array( 'width' => $width, 'height' => $height, 'crop' => $crop );
    		}

    and

    // try and get the width and height from the image attributes
    							if ( ! empty( $og_image['og:image'] ) ) {
    								if ( preg_match( '/ width=[\'"]?([0-9]+)[\'"]?/i', $tag_value, $match) )
    									$og_image['og:image:width'] = $match[1];
    								if ( preg_match( '/ height=[\'"]?([0-9]+)[\'"]?/i', $tag_value, $match) )
    									$og_image['og:image:height'] = $match[1];
    							}

    this is unneeded stuff, really… recheck your code and simplify, this is my suggestion. The plugin, as it is now, fails with external images for sure…then i didn’t test deeply, maybe it works fine when you don’t use the preg_match…but the preg_match part must be reviewed… bye

    width / height missing or too small for ngfb-opengraph

    you have to avoid this, it’s pointless.
    Please get the image size from that simple php function…
    thanks

    Plugin Author JS Morisset

    (@jsmoriss)

    @hero12 :

    I’m not sure how to comment on your messages – they’re a little bit all over the place, and most of your observations are incomplete or wrong. Here’s a FAQ that might help clear up some of your questions / assumptions:

    http://surniaulula.com/codex/plugins/nextgen-facebook/faq/how-does-ngfb-find-detect-select-images/

    If you had a single issue / comment, please open a new thread (instead of posting off-topic comments in an existing thread) and I will happily answer you. Please keep it to one subject at a time, so I can clear up any confusion for you before moving on to a second question.

    Thank you,

    js.

    Thread Starter marciano1

    (@marciano1)

    Thanks hero12 for your help.
    The problem I had was two plugins managing og data: SharePress and NGFB
    SharePress was installed before NGFB.
    I unchecked all SharePress og managing options but og:image because FB post took a 200x pix instead of 600x despite I had set so in NGFB.
    The problem was that featured images were uploaded previous to disable SharePress og:image managing.
    So, each draft post I have created before that I am deleting and uploading again featured images to get NGFB manage share sizes.
    And it works.
    I know that old posts would not display correctly (NGFB warns me when I edit them) but they are already cached in FB so I guess I don’t have to care about, even if I decide to repost (guessing FB has lifetime caches, if not I would have to change featured image by a new one.

    I know a little php coding but I’m afraid to handle WP codes I never internalized but some small adds and changes in my child-theme.

    the image at the bottom is not taken anyhow…
    so it’s definitely a bug

    How do you know that?

    How you get the width/height of the image?
    If you search for the tags width height in html is wrong, you have to code in php something like getimagesize(“$url”); and then you have width in $size[0] and height in $size [1]

    I don’t handle featured image size by myself, they are around 1920x pix, it is NGFB who creates resized copies like nnnn600x315.jpg
    Image upload window (when creating an post with a single image, not video) allows me to select from some image sizes: thumbnail, medium, large, custom.

    What is ATM?

    My posts consist in a single image and a description or an embedded youtube video.

    Here’s
    a search which result contains both kind of posts. Bottom image belongs to footer.php
    Image url is <img class="size-large wp-image-1312" src="http://uruguaydesdeloalto.com/wp-content/uploads/2015/06/STQ_5563A-1024x680.jpg" alt="Foto aΓ©rea de la Isla Gorriti en Punta del Este, Maldonado" data-wp-pid="1312" width="625" height="415">

    Thanks again

    pardon, thanks for your comments…
    it’s easier than you can think… already explained.

    it’s enough to take the image size by getimagesize();

    it’s pointless in the other way, ’cause on the post there may be external images without width/height tags and you can’t force users to always write width= and height= . If not, you ignore the images? No, THIS is wrong πŸ˜‰

    with getimagesize() you bypass any issue easily with a few lines of code.
    the only issue COULD be a temporary connection problem, but that may be tolerated ’cause is really sporadic. Even in that case (and, if more images on the post content) you can always do a cycle to get the found and correct image in the cycle. The problem is if you steadily ignore the img without width height tags, instead.
    thanks

    so, you could even do for first

    // try and get the width and height from the image attributes

    if you don’t want to delete that code part…
    but then, if not image found by that tags method, you also do the getimagesize() part…(or both functions, why not?) so you’re sure to include images, if found.

    this is a temporary workaround on lib/media.php

    // try and get the width and height from the image attributes
    if ( ! empty( $og_image['og:image'] ) ) {
    //if ( preg_match( '/ width=[\'"]?([0-9]+)[\'"]?/i', $tag_value, $match) )
    $size = getimagesize("$attr_value");
    $og_image['og:image:width'] = $size[0];
    //if ( preg_match( '/ height=[\'"]?([0-9]+)[\'"]?/i', $tag_value, $match) )
    $og_image['og:image:height'] = $size[1];
    }
    Plugin Author JS Morisset

    (@jsmoriss)

    @hero12 :

    Thank you, but your suggestions are off-topic for this thread. If you would like to discuss specific features / options, please start a new thread, as requested earlier.

    Your suggestion is under consideration. Using getimagesize() involves considerable overhead (for the TCP connection and image transfer), which can be mitigated by caching features, but maintenance / refresh of the cache would require additional effort (using a GET HEAD to validate modification times / size to use / discard the cached information). Please take this to another thread if you have any comments.

    Thanks,

    js.

Viewing 15 replies - 1 through 15 (of 16 total)
  • The topic ‘og:image problem’ is closed to new replies.