How do I add an image to an item in RSS 2.0?

后端 未结 9 868
青春惊慌失措
青春惊慌失措 2021-02-03 23:50

Is there a way to send only an Image with a link and some alt text for each item in an RSS feed?

I looked at the enclosure tag but this is only for videos

相关标签:
9条回答
  • 2021-02-04 00:17

    The enclosure element can be used to transmit pictures. The RSS 2.0 spec is quite clear about that, saying that the type is a MIME type. It does not say it is restricted to audio or video.

    Here's an example: a set of photo feeds from Agence France Presse

    0 讨论(0)
  • 2021-02-04 00:23

    One of solutions is to use CDATA in description

    <![CDATA[
      Image inside RSS
      <img src="http://example.com/img/smiley.gif" alt="Smiley face">         
    ]> 
    

    Note, that you may have a problem with hotlink prevented site.

    0 讨论(0)
  • 2021-02-04 00:25

    Since you are using php you can use htmlentities() to encode the html tags. They look horrible in the xml but RSS readers know what to do with it.

    http://php.net/manual/en/function.htmlentities.php

    0 讨论(0)
  • 2021-02-04 00:28

    To work with the Mailchimp RSS to email feature, they expect the image to be specified in a <media:content> element inside <item>. This is their source for the feed item's image macro in their templates.

    Thus, you need to add to the declarations

    xmlns:media="http://search.yahoo.com/mrss/
    

    Then inside the <item> element add

    <media:content medium="image" url="http://whatever/foo.jpg" width="300" height="201" />
    

    Without the extra declaration, the feed is invalid since media:content is not a known element.

    0 讨论(0)
  • 2021-02-04 00:30

    Inside tag ITEM

    <image:image xmlns:image="http://web.resource.org/rss/1.0/modules/image/">
    

    http://domain. com/image.jpg < /image:image>

    Inside Description Tag

    <![CDATA[
        Some Text..
        <br/><img src='http://domain. com/image.jpg' ><br/>
        More Text
    ]]>
    
    0 讨论(0)
  • 2021-02-04 00:34

    This is possible in RRS2,

    see http://cyber.law.harvard.edu/rss/rss.html#ltenclosuregtSubelementOfLtitemgt

    So you have to use the enclosure tag, to add media

    0 讨论(0)
提交回复
热议问题