开发者

How to pass image entry in atom rss feed. in rails 3.1

every time people give tutorials on how to make atom rss templates, but my question here is how can i pass in and image in the rss format. for instance i have this code sample in rss

atom_feed :language => 'en-US' do |feed|
  feed.title @title
  feed.updated @updated

  @news_items.each do |item|
    next if item.updated_at.blank?

    feed.entry( item ) do |entry|开发者_StackOverflow社区
      entry.url news_item_url(item)
      entry.title item.title
      entry.content item.content, :type => 'html'

      # the strftime is needed to work with Google Reader.
      entry.updated(item.updated_at.strftime("%Y-%m-%dT%H:%M:%SZ")) 

      entry.author do |author|
        author.name entry.author_name)
      end
    end
  end
end

where can i display the image of the article and how do i do it


The Atom format (http://www.atomenabled.org/developers/syndication/) supports an icon (square) and a logo (rectangular)... so in your block

entry.icon '/path/to/my/icon.png'
entry.logo '/path/to/my/logo.png'

EDIT: serves me right for not checking some code. Those elements are optional elements for the feed element, not the entry. Try:

feed.icon '/path/to/my/icon.png'
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜