• Resolved robertopp

    (@robertopp)


    Hi,

    First of all thanks for such an amazing plugin… super simple to use and straight forward.
    Thumbs up!

    On the other hand, I have a THEME installed which you can PIN (pinterest) the featured images and/or all images… when I used the featured image with your plug in the “img src” is the following”
    data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7

    Making my PIN IT useless :/ any clues? this is the message i received when try it ti PIN IT:
    “Parameter ‘image_url’ (value http:) is not a valid URL format.”

    Thanks in advance!

    https://ww.wp.xz.cn/plugins/external-featured-image/

Viewing 3 replies - 1 through 3 (of 3 total)
  • Thread Starter robertopp

    (@robertopp)

    Theme used: StreetStyle BlogVersion: 1.0 By streetstyle
    This is the theme PHP i found on PINIT if this helps:

    <?php
    if ( streetstyle_get_theme_setting(‘pinit_images’) ) {
    $img = wp_get_attachment_image_src(get_post_thumbnail_id(),’full’);
    $link = ‘https://pinterest.com/pin/create/button/?url=&#8217;. urlencode(get_permalink(get_the_ID())).’&media=’. urlencode($img[0]).’&description=’ . urlencode(get_the_title());
    ?>
    class=”post_label label_pinit”
    ><?php esc_html_e(‘Pin It’, ‘streetstyle’); ?>
    <?php
    }
    ?>

    Plugin Author David Aguilera

    (@davilera)

    Hi!

    First of all, thanks for your kind words. I really appreciate your liking our plugin 🙂

    In order to add an external featured image, our plugin applies a few tricks:

    First of all, it assumes that a certain WordPress function is used for rendering the featured image. In particular, it only works if (get_)the_post_thumbnail is used, because it’s the only one we can hook into. If other functions (such as a combination of wp_get_attachment_image_src and get_post_thumbnail_id) are used, then the plugin doesn’t work.

    Second, the (external) featured image is rendered using an img tag whose src attribute is a transparent gif. The actual featured image is set via CSS, setting it as the background property of said img tag. Using this approach, we can scale the transparent gif to the proper size and the actual featured image (which is set via CSS background, remember) can be scaled and cropped properly, without losing its aspect ratio.

    That probably explains why pinning a featured image returns this:

    data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH...

    This is a 1px transparent gif image.

    Now, by looking at the snippet you shared, it looks like you can manually set the image that has to be pinned. If you look closely at it, you’ll realize it uses the two functions I said our plugins is not compatible with: wp_get_attachment_image_src and get_post_thumbnail_id. One possible solution can be the following:

    ...
    $img = wp_get_attachment_image_src(get_post_thumbnail_id(),'full');
    if ( function_exists( 'uses_nelioefi' ) and uses_nelioefi( get_the_ID() ) {
      $img = array( nelioefi_get_thumbnail_src( get_the_ID ) );
    }
    ...

    As you can see, we simply add a tiny if clause after the $img variable is initialized. This is what we’re doing: we check if the current post has an external featured image set and, if it does, we overwrite the $img variable so that it contains the actual featured image.

    Try to apply the previous tweak and let us know if it solved your issue.

    All the best,
    David

    Plugin Author David Aguilera

    (@davilera)

    It’s been a while since OP last replied, so I’m marking this topic as resolved.

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

The topic ‘img src: data:image/gif;base64’ is closed to new replies.