Viewing 12 replies - 1 through 12 (of 12 total)
  • Plugin Author David Aguilera

    (@davilera)

    Hi! If you take a look at WPBeginner’s tutorial, you’ll see that you can easily add the featured image as follows:

    function rss_post_thumbnail( $content ) {
      global $post;
      if ( has_post_thumbnail( $post->ID ) ) {
        $content = '<p>' . get_the_post_thumbnail( $post->ID ) . '</p>';
        $content .= get_the_content();
      }
      return $content;
    }
    add_filter( 'the_excerpt_rss', 'rss_post_thumbnail' );
    add_filter( 'the_content_feed', 'rss_post_thumbnail' );

    As you may know, Nelio External Featured Images only works if your theme uses either get_the_post_thumbnail or the_post_thumbnail. Apparently, this is the case in the RSS feed. Then, why does this not work?

    Our plugin prints the following image tag:

    <img src="transparent.gif"
      style="background:url( http://domain.com/external-image.jpg )" />

    (it’s not exactly that tag, but it’s pretty close).

    In order to overcome this issue, we need to use a slightly different image tag:

    <img src="http://domain.com/external-image.jpg" />

    where the image’s URL is placed in the src attribute.

    TL;DR

    If you want the image to work properly on RSS, use the following solution:

    function rss_post_thumbnail( $content ) {
      global $post;
      if ( function_exists( 'uses_nelioefi' ) &&
          uses_nelioefi( $post->ID ) ) {
        $img = nelioefi_get_thumbnail_src( $post->ID );
        $content = '<p><img src="' . esc_attr( $img ) . '" /></p>';
        $content .= get_the_content();
      } else if ( has_post_thumbnail( $post->ID ) ) {
        $content = '<p>' . get_the_post_thumbnail( $post->ID ) . '</p>';
        $content .= get_the_content();
      }
      return $content;
    }
    add_filter( 'the_excerpt_rss', 'rss_post_thumbnail' );
    add_filter( 'the_content_feed', 'rss_post_thumbnail' );

    I hope this helps!

    Thread Starter nickilewis65

    (@nickilewis65)

    I entered that code into the function.php and still no images showing

    Plugin Author David Aguilera

    (@davilera)

    Can you please share the link to your blog?

    Thread Starter nickilewis65

    (@nickilewis65)

    Plugin Author David Aguilera

    (@davilera)

    Is any of the “recent posts” (i.e. the ones that appear in the RSS) using Nelio EFI?

    Thread Starter nickilewis65

    (@nickilewis65)

    Yes they all are because I have been housing my images on flickr

    Plugin Author David Aguilera

    (@davilera)

    I see you’re using version 1.3.x of our plugin, which (unfortunately) had quite a few bugs.

    Please, try using the stable release 1.2.0. It’s much more reliable (even though it has some limitations).

    Thread Starter nickilewis65

    (@nickilewis65)

    is there a easy way to roll back to that version?

    Plugin Author David Aguilera

    (@davilera)

    Yes, simply deactivate and uninstall your current version and install the plugin again.

    There should be no problems, but I always recommend to backup your WordPress before installing new/updating plugins.

    Thread Starter nickilewis65

    (@nickilewis65)

    Ok I did that and still not seeing the images

    Plugin Author David Aguilera

    (@davilera)

    Maybe you’re behind a cache? It’s pretty strange.

    Anyway, try to tweak the previous code and see if you can modify your RSS file somehow (not necessarily using an image). For instance:

    function rss_post_thumbnail( $content ) {
      return 'Testing...';
    }
    add_filter( 'the_excerpt_rss', 'rss_post_thumbnail' );
    add_filter( 'the_content_feed', 'rss_post_thumbnail' );

    WARNING: all posts in your RSS should have the same content now (“Testing…”).

    If all posts have the same content, then the previous code for inserting featured images should work. If this latter change didn’t work, then the problem lies somewhere else.

    Thread Starter nickilewis65

    (@nickilewis65)

    Not sure I put it in right place cause it did nothing

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

The topic ‘RSS Feed’ is closed to new replies.