• Resolved hero12

    (@hero12)


    Hello,
    good job ??

    anyway, there is a trick on Facebook to let it read the correct image:
    eg.

    <meta property="og:image:width" content="640" />
    <meta property="og:image:height" content="360" />

    so, you should get the post image width and height
    and insert those properties in the declaration.

    In this way Facebook is used to always get the image. (if >= 200 x 200 pixels)
    Default image is good for sure, but the post image (if any) is always the best ?? please implement this and your plugin is perfect then..

    thank you very much
    Facebook Sharing best practices
    Section Pre-caching images

    https://www.ads-software.com/plugins/wp-facebook-open-graph-protocol/

Viewing 10 replies - 1 through 10 (of 10 total)
  • Thread Starter hero12

    (@hero12)

    and also, use this as prefix:

    prefix="og: https://ogp.me/ns# fb: https://ogp.me/ns/fb#"
    Plugin Author Chuck Reynolds

    (@ryno267)

    Hey Hero12

    I’ve considered adding the image size but haven’t yet as it’s not required as per their documentation; and they do a good job of finding the proper image size as it is. The new version I have in final testing right now changes the way images are presented to FB and will resolve the problems of multiple images being presented and FB choosing one based on size instead of what a site wants to be presented.

    That should be out fairly soon. Just busy with work and needs more testing.

    As for the prefix – that’s already in the new version as well.

    Cheers!

    Thread Starter hero12

    (@hero12)

    hi ?? that’s required by Pre-caching… so you’re not forced to do a debugging. Tested ok, trust me…
    obviously the image size must be ≥ 200×200

    have a nice day

    Thread Starter hero12

    (@hero12)

    so, you could do…
    eg.
    if ($post_image), get the width/height…
    if $post_image size ≥200×200
    insert… otherwise width/height of the default image.
    Also, you could let the user choose to always use the default image (with its width/height) as an option. (not only to set…)
    1) always use the default image? if yes, you just insert the default image and width/height
    2) if not, you run that function and evaluate…
    bye

    Thread Starter hero12

    (@hero12)

    at the moment with the current code…

    echo '<meta property="og:image" content="' . esc_url( apply_filters( 'wpfbogp_image', $image ) ) . '"/>' . "\n";
    $dimgurl = esc_url( apply_filters( 'wpfbogp_image', $image ) );
    $size = getimagesize("$dimgurl");
    echo '<meta property="og:image:width" content="' . $size[0] . '"/>' . "\n";
    echo '<meta property="og:image:height" content="' . $size[1] . '"/>' . "\n";

    ’cause you have width in $size[0] and height in $size[1]

    ?? then if you want to do other checks is good for sure

    Thread Starter hero12

    (@hero12)

    and… maybe an error somewhere on your code…

    ’cause on a post tested now, instead of the first image it takes a little google png from sharing bar at the very bottom… so it skipped many good images and you have to understand why…

    you need to keep the first image on the post for sure OR you do a check to see if the image is big enough and according to this you insert the default image or not… I don’t think that’s good if you always insert the default image, before any other image…

    hope this helps

    Thread Starter hero12

    (@hero12)

    ok, understood ??
    there’s a conflict with the “a3 Lazy Load” plugin
    ’cause it adds
    data-src= with the correct img url and the img src, instead, is something like

    data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7

    so i need to verify how to fix…or you can help about this

    Thread Starter hero12

    (@hero12)

    I tried with this

    $output = preg_match_all( '/<img.+data-src=[\'"]([^\'"]+)[\'"].*>/i', $content, $matches );

    while the regex is correct, it doesn’t work anyway… maybe the conflict is the moment when a3 Lazy Load changes the url… otherwise I can’t understand, it should correctly match the url, even tested on regex101.com

    can you try to install the a3 Lazy Load and test it? thanks

    Thread Starter hero12

    (@hero12)

    ok, no, it’s not a unique issue related to a3 Lazy Load ’cause I disabled it (and anyway, the img src are still there ’cause that plugin allows a noscript tag with the proper img src, so you can avoid conflict with that)

    your code always skips the main images on a specific post…and finds the last image on the content

    eg. code first image on the post content

    <div id="attachment_47162" class="wp-caption aligncenter" style="width: 640px"><img class="wp-image-47162 size-large" src="https://example.com/wp-content/uploads/2015/06/BKlduBK-640x477.jpg" alt="BKlduBK" width="640" height="477"/>
    <p class="wp-caption-text"><em>Image via user goawaywhatsapp on Reddit’s /r/DJs</em></p>

    instead it finds the very last image:

    <img src="https://example.com/folder/google.png" title="Google+" class="ssba ssba-img" alt="Share on Google+"/>
    Thread Starter hero12

    (@hero12)

    so, the errors are:
    1) doesn’t find the correct image, but the last one only… you have to check your preg_match and array method… but didn’t you test it?
    2) insert default image only when the found image is not big enough (must be >=200×200)
    3) for the image size already wrote about it…

    bye

Viewing 10 replies - 1 through 10 (of 10 total)
  • The topic ‘Facebook trick, debugger really not needed…read’ is closed to new replies.