Page 1 of 1

Add images to rss when image is not inside $entry.body

Posted: Sun Mar 30, 2008 4:48 pm
by Don Chambers
I have a template that is using extended property fields for images, rather than having the images contained within the entry body. How can these images be included in the feed?

Re: Add images to rss when image is not inside $entry.body

Posted: Sun Mar 30, 2008 7:00 pm
by yellowled
Don Chambers wrote:I have a template that is using extended property fields for images, rather than having the images contained within the entry body. How can these images be included in the feed?
Disclaimer: This is untested, I have never used it myself, and I don't have approriate knowledge of xml and/or RSS to back it up. Maybe this doesn't conform to xml and/or RSS standards.

I guess you have looked into /templates/default/ before. Ever examined those feed_*.tpl files closer? They're just like "normal" .tpl files, but instead of PHP/(X)HTML for parts of the blog, they provide XML for the feed, and you can of course use smarty in them, which means you can include images from extended property fields.

I guess you can take it from here? Might be nice to post a working code example later for future reference, though. You'll probably also want to check out if there are any XML and/or RSS standards blocking this, but I can figure out why there should be any.

YL

Posted: Sun Mar 30, 2008 8:54 pm
by Don Chambers
I know the tpl files are there... but I was hoping for an alternative. Those tpls check to see if $entry.body is not empty, and if not, it then prints {$entry.feed_body|@escape}.... so at some point, $entry.feed_body is created and contains not only the image, but all the proper formatting for that image.... probably because formatting is performed inline by the media manager when an image is inserted into an entry.

Not sure exactly what I was thinking... maybe something like the ability to define the $entry.feed_body to be all content wrapped within a certain class or something. But that probably would not work because the feed is independent of entries.tpl.

Posted: Sun Mar 30, 2008 10:23 pm
by garvinhicking
Hi!

You can basically use the same coding than within your entries.tpl file, simply append your custom stuff into the place where $feed_Body already goes into, simply add more to that XML element.

Only you need tomake sure that "<" and ">" are escaped to > and <so that they can be usedwithin XML.

Regards,
Garvin

Posted: Sun Mar 30, 2008 11:39 pm
by Don Chambers
Yeah, I know the characters would need to be escaped... but I was hoping for an option that would not require providing all the different, custom rss tpls, but I cannot come up with anything, and it doesn't sound like anyone can either!! Oh well!!! More smarty templates I guess!

Posted: Sat Apr 05, 2008 11:26 pm
by Don Chambers
Am I missing something here? I copied the file feed_2.0.tpl to my template, modified it, but the changes are not being reflected in my rss2 feed. I have also cleared /templates_c/. Am I working with the wrong file?

UPDATE: Seems to have been firefox.... the file was being cached, and for whatever reason, firefox didn't seem to see any need to load the modified file.

This experience did lead me to a nice firefox add-on for viewing the cache:
https://addons.mozilla.org/en-US/firefox/addon/2489

Posted: Sun Apr 06, 2008 2:35 am
by mgroeninger
Doh, completely got confused there and posted a big old long message about something else entirely...

Sorry about that.

Posted: Sun Apr 06, 2008 6:09 pm
by Don Chambers
Are these assumptions correct for the feed tpl's?
  • RSS 0.91, 1 & 2 requires html to be escaped.
    Atom supports xhtml, so does not need to be escaped.
    OPML doesn't even show the entry body, so no point in adding images.

Posted: Sun Apr 06, 2008 7:58 pm
by garvinhicking
Hi!

Absolutely correct, yes.

Regards,
Garvin