Forums

[resolved] Images not appearing in RSS feed (10 posts)

  1. bg2326
    Member
    Posted 5 years ago #

    While I realize that this is probably not the best practice, I will occasionally link to images contained within my site by adding the img src HTML code directly in my post title.

    The problem, however, is that these images that I link to do not show up in the RSS feed for my site, so anyone using a reader won't see the images... just the text.

    Any suggestions? I realize this is an obscure question and a problem that I somewhat got myself into, but thought it might not hurt to ask. Thanks.

  2. Otto
    Tech Ninja
    Posted 5 years ago #

    If your images don't use the full URI to the image, with http and everything, then it's likely they won't show up in readers.

  3. bg2326
    Member
    Posted 5 years ago #

    Thanks for your response. I am using the full URI (http and everything) on all my title image links for precisely this reason, but still nothing shows up... perhaps it has to do with my wp-rss2.php file? I currently have this for the title:
    <title><?php the_title_rss() ?></title>

    While I am very familiar with HTML, I am not as experienced with PHP.

  4. Otto
    Tech Ninja
    Posted 5 years ago #

    Ummm.. What? Title Image Links? I don't understand.

    Provide a link to your site so we can look at it. Then maybe we'll understand what you're trying to do.

  5. bg2326
    Member
    Posted 5 years ago #

    Sorry, by "title image links" I was referring to the img src HTML code placed directly in my post title.

    The site is: http://www.pulsecreativepartners.com/

    This site was my first one using WordPress, and I know there are portions of it that are not by the book. Originally when I set it up, I wanted the images above the title and the best solution I found to do that was by including the html link to the URI of the image. For example, I will put something like this in the title field:
    <img src="http://www.pulsecreativepartners.com/postimages/imagename.jpg" width="430" height="143" />Post Title

    Looking back, I realize this probably wasn't the best solution, but at the time, it gave me the flexibility I was looking for.

    I understand this may be why the images aren't showing up in the RSS feed, but wasn't absolutely sure.

    Thanks.

  6. Otto
    Tech Ninja
    Posted 5 years ago #

    Ahhh.. Okay, I see.

    Yes, all HTML is stripped out of titles in feeds. This is WordPress doing this. If you look in default-filters.php, you'll find this line:
    add_filter('the_title_rss', 'strip_tags');
    The "strip_tags" function is what removes all the HTML tags from the title for the feeds. You could comment this out and see what happens, but no guarantees. Probably will just break the feed.

    It's legal to have HTML in a feed, but only if it has been entity-encoded or put inside a CDATA block. And even then, I would imagine most RSS readers wouldn't display it properly, they're expecting text inside a title tag, not HTML.

    But you could add the htmlentities function to the title filter to try to allow it to work. Just add this line in that default-filters.php:
    add_filter('the_title_rss', 'htmlentities');

  7. bg2326
    Member
    Posted 5 years ago #

    Thank you so much for your clear explanation. You were correct in both instances... removing 'strip_tags' broke the feed, and while adding 'htmlentities' did not break the feed, the images still did not appear (on my reader).

    Thanks for your time on this issue. It is satisfying at least to know why they aren't appearing, and it is something I will keep in mind for the future.

  8. Otto
    Tech Ninja
    Posted 5 years ago #

    Adding the htmlentites certainly won't work unless you also remove the strip_tags at the same time. But even then, your reader may not like images in titles. No cure for that.

  9. bg2326
    Member
    Posted 5 years ago #

    Right, I understood that. Thanks for following up though.

  10. Puissance
    Member
    Posted 5 years ago #

    Hi everyone, I am also interested in having images within my feed.

    The feed here has images within its feed and the site is using WordPress.

    How can I do that as well?

    Thanks!

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags