Support » Plugin: Nelio External Featured Image (discontinued) - Available in Nelio Content » Theme : NewsMag | Image doesn't appear on facebook page when I share my post.

  • Resolved vinaythoke

    (@vinaythoke)


    Hello there,

    I just love this plugin. You are amazing at support.

    I have come a long way fixing a lot of stuff myself by using your comments on other people’s similar problems. But somehow, I couldn’t manage to fix this myself using your comments on the same issue for other wordpress themes.

    Problem : “Image not displaying on using facebook share”. Not even when I copy URL and share on facebook.

    Sample post from my website : http://bit.ly/NewsMagExternalImageIssue

    What I tried doing : Inserting a Meta tag in the header, Copying some other stuff that you’d posted there about facebook open graph (og) in functions.php. But unfortunately none of that worked. Maybe because of the different theme?

    I saw that you’ve fixed quite a few other issues of this amazing plugin with NewsMag theme for other users. I request you to fix this last one for me. I really have tried a lot fixing it. I’m ready to send you functions.php or other files of the theme if you need them.

    Also, while telling me how to fix it, please whatever code you give me, let me know where to exactly put it in the respective php files.

    That’s enough.
    Thank you so much in advance,
    Vnay

    https://wordpress.org/plugins/external-featured-image/

Viewing 5 replies - 1 through 5 (of 5 total)
  • Hello David,

    I know you must be busy. I request you to take few moments out of your precious time to fix this. I’m sure it will just take you few minutes to create that small code and post here.

    Many thanks in advance,
    Vnay

    Plugin Author David Aguilera

    (@davilera)

    Hi!

    I see that your website (bollywoodscope, right?) uses our plugin, and that your header defines Facebook’s Open Graph Image. I guess that’s because you tweaked your functions.php file.

    If you take a look at the source code of your one of your posts, you’ll notice a couple of things:

    • The meta tag og:image appears twice. First in line 7, right after the title, and then in line 90, surrounded by other og:* tags.
    • The content (in this case, that should be the image URL) of these two metas are different. The former is http://example.com/external-feat-image.jpg and the latter is http://www.bollywoodscope.com/.
    • None of them point to the real featured image.

    So, taking into account all of this, here’s what you need to fix:

    • Make sure that only one og:image meta appears. I don’t know if you added both, or one of them is included by your theme… you’ll have to investigate this, but only one of them should appear.
    • Make sure that the content of the tag is the external featured image’s URL. You’ll need to use something like this:
      $image_url = nelioefi_get_thumbnail_src( get_the_ID() );

      And remember, if you need to echo that result, make sure to escape it before:

      <meta property="og:image" content="<?php
        echo esc_attr( $image_url );
      ?>" />

    I hope this helps!

    Best,

    Hi David,

    Many many thanks for responding. I really appreciate that you’ve taken out some time to provide a solution. I did remove the duplicate OG tags.

    I did put this meta property in the header as suggested by you:

    <meta property="og:image" content="<?php
      echo esc_attr( $image_url );
    ?>" />

    However, when I view the page source for any of the posts, the meta content shows nothing but just the quotes (“”)

    I feel Somehow it’s not grabbing the $image_url.

    You have provided me this code for the content:

    $image_url = nelioefi_get_thumbnail_src( get_the_ID() );

    But I don’t know where to put it. And seems that’s precisely the reason It’s not fixed yet.

    I’m a complete noob, so please guide me through how to go about it. Putting which code in what file?

    Here’s my functions.php file code: http://codepad.org/j2Zr4RlJ
    Here’s my header.php code: http://codepad.org/zWCqyAXa

    Thank you so much in advance,
    Vinay

    Plugin Author David Aguilera

    (@davilera)

    I see you’ve added the code directly in your header.php file. Even though that’s not the best way to do this, it should probably do the trick. However, instead of this snippet:

    <meta property="og:image" content="<?php
      echo esc_attr( $image_url );
    ?>" />

    use this one:

    <?php
    if ( is_single() ) {
      if ( function_exists( 'uses_nelioefi' ) &&
           uses_nelioefi( get_the_ID() ) {
        $image_url = nelioefi_get_thumbnail_src( get_the_ID() );
        ?>
          <meta property="og:image" content="<?php
            echo esc_attr( $image_url );
          ?>" />
        <?php
      }//end if
    }//end if
    ?>

    This will only add the featured image if we’re in a single post and the post uses Nelio.

    Finally, I don’t know if Facebook uses the first og:image meta or the last, so maybe you should add the previous snippet right before closing the </head> tag.

    Best,

    Hi David,

    You are amazing! It WORKED. Never doubted you. :p

    Actually there was this parsing error on line 4 in the script you’ve given above, however I corrected it by adding one more bracket. 🙂

    I’m so thankful to you. Let’s see how everything goes for a few days and I will be sending a donation your way.

    Many thanks for being there for us. You have developed an amazing, much needed plugin. Kudos! And more power.

    Cheers!
    Vinay

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Theme : NewsMag | Image doesn't appear on facebook page when I share my post.’ is closed to new replies.