views:

61

answers:

1

Trying to create a simple RSS2 Feed that I could later pass on to FeedBurner but can't get RSS feed to display images at all.

Also, from what I have read having xml.instruct! on top might cause IE to complain it's not a valid feed. Is this true?

My Code looks like

xml.instruct!

xml.rss "version" => "2.0", "xmlns:dc" => "http://purl.org/dc/elements/1.1/" do
 xml.channel do

   xml.title           "Store"
   xml.link            url_for :only_path => false, :controller => 'products'
   xml.description     "Store"
   xml.pubDate         @products.first.updated_at.rfc822 if @products.any?

   @products.each do |product|
     xml.item do
       xml.title       product.name
       xml.pubDate     (product.updated_at.rfc822)
       xml.image do
         xml.url       domain_host + product.product_image.url(:small)
         xml.title     "Store"
         xml.link      url_for :only_path => false, :controller => 'products'
       end
       xml.link        url_for :only_path => false, :controller => 'products', :action => 'show', :id => product.permalink
       xml.description product.fine_print
       xml.guid        url_for :only_path => false, :controller => 'products', :action => 'show', :id => product.permalink
     end
   end
 end

end

Updated - snippet with and without image tag in description

Without image_tag in description - From Firefox

<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/"&gt;
  <channel>
    <title>Test Me</title>
    <link>http://localhost:3000/products&lt;/link&gt;
    <description>Test Me</description>
    <pubDate>Mon, 21 Jun 2010 14:51:11 +0000</pubDate>
    <item>
      <title>Cylinder</title>
      <pubDate>Mon, 21 Jun 2010 14:51:11 +0000</pubDate>
      <image>
        <url>http://localhost:3000/assets/products/1/small/product_1.jpg&lt;/url&gt;
        <title>Test Me</title>
        <link>http://localhost:3000/products&lt;/link&gt;
      </image>
      <link>http://localhost:3000/products/1&lt;/link&gt;
      <description>&lt;p&gt;&lt;h2&gt;Cylinder 2467.d&lt;/h2&gt;
This cylinder was designed for ruggedness and high performance&lt;/p&gt;</description>
      <guid>http://localhost:3000/products/1&lt;/guid&gt;
    </item>
  </channel>

</rss>

With image_tag in description - From Firefox

<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/"&gt;
  <channel>
    <title>Test Me</title>
    <link>http://localhost:3000/products&lt;/link&gt;
    <description>Test Me</description>
    <pubDate>Mon, 21 Jun 2010 14:46:54 +0000</pubDate>
    <item>
      <title>Cylinder</title>
      <pubDate>Mon, 21 Jun 2010 14:46:54 +0000</pubDate>
      <image>
        <url>http://localhost:3000/assets/products/1/small/product_1.jpg&lt;/url&gt;
        <title>Test Me</title>
        <link>http://localhost:3000/products&lt;/link&gt;
      </image>
      <link>http://localhost:3000/products/1&lt;/link&gt;
      <description>&lt;img alt="Product_1" src="/assets/products/1/small/product_1.jpg?1276967922" /&gt;&amp;lt;p&amp;gt;&amp;lt;h2&amp;gt;Cylinder 2467.d&amp;lt;/h2&amp;gt;
This cylinder was designed for ruggedness and high performance&amp;lt;/p&amp;gt;</description>
      <guid>http://localhost:3000/products/1&lt;/guid&gt;
    </item>
  </channel>

</rss>
A: 

Are your image paths relative or do they contain the full URI to the resource? Double check the source made by your script for this kind of thing. Google reader will try and correct this, but not every RSS tool will do the same.

danp
full url is there, firefox and safari don't display it, but when I view the source it does show it. If I try to add an image tag in the description it does then show the image but then all the html styling is also shown. i.e. <ul>, <p>, etc.
pcasa