Including an Image in RSS?
This is an open discussion with 5 replies, filed under XSLT.
Search
Define “not working”… are you not seeing the output you expect? Is the feed not validating?
AFAIK you can only have one image per feed, because it’s the image for the channel
as a whole, not one for each item
. So having it inside your for-each
loops seems like it could cause problems.
Sorry, when I get frustrated a tend to blurt out “Someone else solve it for me!”.
The channel/item issue DID point me in the right direction, however I’ve run into a new problem… well, pretty much the same problem:
I got rid of everything Image and setup the enclosure tag instead, so my for-each is the following:
<enclosure url="{$root}/image/1/140/0/images/{event-photo/item/image/filename}" length="{event-photo/item/image/@size}" type="{event-photo/item/image/@type}" />
Only the image is broken despite the length, type and link data come through just fine. The SRC for the image comes back as src=”feed:///icon32/jpg”
Why don’t you put it in the ‘description’ element (and do some “encoding” by hand)? This is working for me, like so:
<description> <xsl:if test="image"> <xsl:text><p></xsl:text> <xsl:text><img src="</xsl:text> <xsl:value-of select="$root"/> <xsl:text>/image/2/216/134/5</xsl:text> <xsl:value-of select="image/@path"/> <xsl:text>/</xsl:text> <xsl:value-of select="image/filename"/> <xsl:text>" width="216" height="134" alt="" /></xsl:text> <xsl:text></p></xsl:text> </xsl:if> <xsl:value-of select="text"/> </description>
BRILLIANT! Thanks Michael!
:-)
Create an account or sign in to comment.
I’m working on creating a RSS for an events page and would like to include an image, but I can’t figure out what’s wrong with my code that’s not working. Help?