RSS img src is valid but no image gets displayed?

Hi all,

I’ve re-engineered my PHP script to produce a RSS XML file.

The RSS file validates fine via http://validator.w3.org/feed/check.cgi

Unfortunately images don’t show for some reason and I can’t quite pin down why.

The part of the RSS which displays the image is this:

<description><p><img src=“http://www.yootheme.com/images/stories/blog/news_zoo21.jpg” width=“200” height=“200” align=“middle” /></p> </description>

The header of the RSS which I’m writing is as:

fwrite($rss_data_write, "<?xml version=‘1.0’ encoding=‘iso-8859-1’?>\r
");
fwrite($rss_data_write, "<rss version=‘2.0’ xmlns:blogChannel=‘http://backend.userland.com/blogChannelModule’>\r
");
fwrite($rss_data_write, "<channel>\r
“);
fwrite($rss_data_write, “<title>” .$rss_title .”</title>\r
“);
fwrite($rss_data_write, “<link>http://” .$rss_site .”</link>\r
“);
fwrite($rss_data_write, “<description>” .$rss_description .”</description>\r
“);
fwrite($rss_data_write, “<language>” .$rss_language .”</language>\r
“);
fwrite($rss_data_write, “<copyright>http://” .$rss_site .”</copyright>\r
“);
fwrite($rss_data_write, “<lastBuildDate>” .$rss_pubdate .”</lastBuildDate>\r
");
fwrite($rss_data_write, "<docs>[B]http://backend.userland.com/rss[/B]&lt;/docs&gt;\\r\
“);
fwrite($rss_data_write, “<generator>Generated by " .$rss_site_name .” " .$rss_site .”</generator>\r
“);
fwrite($rss_data_write, “<managingEditor>” .$rss_editor_email .”</managingEditor>\r
");
fwrite($rss_data_write, "\r
");

As far as I’m aware the above code is valid and should display the image in img src etc.

I’ve compared the code to other RSS feeds and it would seem I’m doing nothing wrong…in theory.

I’m inclined to believe that either the namespace is being defined problematically or somehow chars are getting inserted somehow which somehow makes any RSS reader fall over when displaying an image.

In IE8 the RSS field yields an image placeholder as if the link was invalid (except it’s not), in other RSS reader it simply doesn’t display the image at all.

Any RSS experts out there that can spot the problem?

Thanks,

Still haven’t solved it but found the below from http://www.webmonkey.com/2010/02/rss_for_beginners/

Two pieces of advice to heed while creating your <description>: Firstly, put in the extra effort to create a well-written, easy-to-read description. In the text-centric world of RSS, you can’t expect an audience to click through to your site if your “teaser” excerpt has little appeal or sense to it. Secondly, if there is HTML code in your description, XML parsers throw a fit unless certain HTML symbols (like the ampersand) are escaped out. Either keep HTML out of your description altogether, or encode it via CDATA, like so:

I would <![CDATA[<b>really</b>]]> rather have
just dropped the bold tag.

To comply with the above I changed the code to:

fwrite($rss_write_file, "<description><![CDATA[" .'<p>' .'<img src="' .trim($rss_content['$rssImage '][$i]) .'"' .' width="' .trim($rss_content['$rssImageWidth '][$i])  .'"' .' height="' .trim($rss_content['$rssImageHeight '][$i]) .'"' .' alt="' .'Sample image' .'"' .' align="middle" /></p>]]>' ."<![CDATA[" .trim($rss_content['$rssDescription '][$i]) ."<br><br>\\r\
");

Which produces an output like this:

<description><![CDATA[<p><img src=“http://www.yootheme.com/images/stories/blog/news_zoo21.jpg” width=“200” height=“200” alt=“Sample image” align=“middle” /></p>]]><![CDATA[Sample text <br><br>
]]></description>

…and yet the image still doesn’t get displayed. It doesn’t matter what image url I provide it (I’ve tried various online images, not just off of my site) so I’m 99.99% sure it’s not a bad img src url being passed.

:rolleyes:

Thank’s for that suggestion.

If I do what you propose I get the below RSS code:

<description><![CDATA[<p><img src="http://www.yootheme.com/images/stories/blog/icon_set_boxes_scribble.jpg
" width=“200” height=“200” align=“middle” /></p> Sample text<br /><br />]]></description>

Sadly this simply goes and throws the phrase “<p><img src=“http://www.laptopmemoryupgrades.co.uk/images/stores/amazon.png” width=“163” height=“95” align=“middle” /></p>” on the page beside the “Sample text”. That’s why I had <![CDATA[ only just before the actual “Sample text” or whatever description goes there.

Here’s the code used to render the RSS, currently configured in the way you suggested:

$array_count = sizeof($content_items);									
	for ($i = 0; $i < $array_count; $i++) 
	{			
			fwrite($rss_write_file, "<item>" ."\\r\
");
			fwrite($rss_write_file, "<title>" .trim($rss_content['$rssTitle '][$i]) ." at " .trim($rss_content['$rssMisc '][$i]) ." - expires on " .trim($rss_content['$rssMisc2 '][$i]) ."</title>\\r\
");
			fwrite($rss_write_file, "<link>" .trim($rss_content['$rssLink '][$i]) ."#" .$i ."</link>\\r\
");
			
			// only proceed this step if this content item has extra content		
			if ($rss_content['$rssHasExtra '][$i] == 1)
			{			
				[COLOR="DarkGreen"]fwrite($rss_write_file, "<description><![CDATA[" .'<p><' .'img src="' .trim($rss_content['$rssImage '][$i]) .'"' .' width="163"' .' height="95"' .' align="middle" /></p> ' .trim($rss_content['$rssDescription '][$i]) ."<br /><br />\\r\
");[/COLOR]	
				
				// go through all extra content of the type below that is part of this content item
				$array_count2 = sizeof($rss_content['$rssDescriptionExtra '][$i]);				
				for ($c = 0; $c < $array_count2; $c++) 
				{	
					//if this is the final instance of extra content append the </description> to the write operation
					if ($c + 1 == $array_count2)
					{
						[COLOR="DarkGreen"]fwrite($rss_write_file, trim($rss_content['$rssDescriptionExtra '][$i][$c]) ."]]></description>\\r\
");[/COLOR]
					}
					else
					{
						fwrite($rss_write_file, trim($rss_content['$rssDescriptionExtra '][$i][$c]) ."<br />\\r\
");
					}
				}
			}
			else
			{
				[COLOR="Red"]fwrite($rss_write_file, "<description>" .'<p><' .'img src="' .trim($rss_content['$rssImage '][$i]) .'"' .' width="163"' .' height="95"' .' align="middle" /></p> ' ."</description>\\r\
");	[/COLOR]
			}					
			
			fwrite($rss_write_file, "<guid>" .trim($rss_content['$rssGUID '][$i]) ."#" .$i ."</guid>\\r\
");		
			fwrite($rss_write_file, "<pubDate>" .trim($rss_content['$rssPubDate '][$i]) ."</pubDate>\\r\
");
			fwrite($rss_write_file, "<author>" .trim($rss_content['$rssAuthor '][$i]) ."</author>\\r\
");
			fwrite($rss_write_file, "<category>" .trim($rss_content['$rssCategory '][$i]) ."</category>\\r\
");
			fwrite($rss_write_file, "</item>" ."\\r\
");
	}	

Please note it’s the code path in green that’s causing the mayhem somehow.

The code path in red could get executed but at present $rss_content['$rssHasExtra '][$i] is always == 1 hence only the green code path is the suspect.


fwrite($rss_data_write, "<description><![CDATA[" . ($rss_description) . "]]></description>\\r\
");

<description><p><img src=“http://www.yootheme.com/images/stories/blog/news_zoo21.jpg” width=“200” height=“200” align=“middle” /></p> <![CDATA[Sample text<br /><br />
]]></description>

The above also doesn’t work.

I’ve attached a created RSS file via my script as a txt file. Just rename the file extention from .txt to .xml to run it in a browser or other RSS reader.

It will show images in Safari but not in IE8 (which I know for a fact shows images in RSS feeds - this can be verified by for example viewing this feed in IE8: http://blog.makezine.com/archive/make_podcast/index.xml), not Chrome, not Firefox, not Opera and not Flock.

I understand now all RSS readers show images, but it should at least show in all that do.

I can’t for the life of me spot any bugs. :confused::confused::confused: