Bonne Méthode Pour Ajouter des Images À Un Flux RSS?

Comme un élément par élément, pas un logo de l'alimentation dans son ensemble.

J'utilise php pour générer mon alimentation avec des valeurs d'une db. Rien n'indique sur firefox, mais si j'ouvre l'url dans google chrome, je peux voir tous les xml de sortie, et ça semble bien pour moi.

Une chose que je ne suis pas sûr au sujet de est y compris les images, j'ai utilisé ce site web et mis en œuvre ce qu'il a dit:

http://twigstechtips.blogspot.com/2010/10/add-image-to-your-rss-feed-item.html

J'ai aussi vu cela DONC, la question ainsi: Flux RSS: pour nourrir les images à votre flux rss . Ce pourrait être la meilleure façon et je suppose il y a une fonction php pour déterminer la taille de fichier d'une image?

La façon la plus commune que j'ai vu, c'est aussi une question DONC: Les Images en flux RSS

J'ai essayé de la validation de l'aliment à tester pourquoi il n'apparaît pas sur firefox, mais parce qu'il est si grand pas de site web, j'ai visité jusqu'à présent peut la valider. Est-il possible que ce est pourquoi il n'apparaît pas sur Firefox (il n'a utilisé à un moment quand j'ai tronqué le CDATA section et avant j'ai essayé d'ajouter des images).

La seule chose c'est que je ne sais pas où il va dans mon alimentation. Veuillez voir le code source et de sortie d'exemple ci-dessous:

Source (moins de choses inutiles comme les comprend...)

header("Content-Type: application/rss+xml; charset=utf-8");

$rssfeed = '<?xml version="1.0" encoding="UTF-8"?>' . "\n";
$rssfeed .= '<rss version="2.0">' . "\n";
$rssfeed .= '<channel>' . "\n";
$rssfeed .= '<title>RSS feed</title>' . "\n";
$rssfeed .= '<link>http://www.website.co.uk</link>' . "\n";
$rssfeed .= '<description>RSS feed from www.website.co.uk</description>' . "\n";
$rssfeed .= '<language>en-uk</language>' . "\n";
$rssfeed .= '<copyright>Copyright (C) 2011 website.co.uk</copyright>' . "\n\n";

$query = 'SELECT * 
          FROM uk_newsreach_article t1
              INNER JOIN uk_newsreach_article_photo t2
                  ON t1.id = t2.newsArticleID
              INNER JOIN uk_newsreach_photo t3
                  ON t2.newsPhotoID = t3.id
          ORDER BY t1.publishDate DESC;';

$result = mysql_query($query) or die ("Could not execute query");


while($row = mysql_fetch_array($result)) {
    extract($row);

    $rssfeed .= '<item>' . "\n\t";
    $rssfeed .= '<title>' . $row['headline'] . '</title>' . "\n\t";

    $link= 'http://www.website.co.uk';
    $url = ' . $link . '/' . $row['newsArticleID'];

    $rssfeed .= '<link>' . $url . '</link>' . "\n\t";
    $rssfeed .= '<guid>' . $url . '</guid>' . "\n\t";

    $text = $row['text'];
    $rssfeed .= '<description><![CDATA[' . $text . ']]></description>' . "\n\t";
    //$rssfeed .= '<description>' . htmlentities($text) . '</description>' . "\n\t";

    //add image
    $rssfeed .= '<media:thumbnail url="' . $row['mediumURL'] . '" height="' . $row['mediumHeight'] . '" width="' . $row['mediumWidth'] . '" />'. "\n\t";

    $rssfeed .= '<pubDate>' . date("D, d M Y H:i:s O", strtotime($row['publishDate'])) . '</pubDate>' . "\n";
    $rssfeed .= '</item>' . "\n\n";
}

$rssfeed .= '</channel>' . "\n";
$rssfeed .= '</rss>' . "\n";

echo $rssfeed;

Exemple De Sortie

<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0">
<channel>
<title>RSS feed</title>
<link>http://www.website.co.uk</link>
<description>RSS feed from www.website.co.uk</description>
<language>en-uk</language>
<copyright>Copyright (C) 2011 website.co.uk</copyright>

<item>
<title>Wear safe but stylish sunglasses on the slopes</title>
<link>http://www.website.co.uk/news/articles/wear-safe-but-stylish-sunglasses-on-the-slopes/800747215</link>
<guid>http://www.website.co.uk/news/articles/wear-safe-but-stylish-sunglasses-on-the-slopes/800747215</guid>
<description><![CDATA[<p>Holidaymakers hitting the slopes this year must remember to pack a pair of sunglasses alongside their skis, one expert has highlighted.</p>
<p>Dharmesh Patel, chairman of the Eyecare Trust, noted that UV protective eyewear is a must for skiers.</p>
<p>&quot;It&#39;s vital that you protect your eyes both when you&#39;re on the slopes and whilst enjoying your apres ski,&quot; he noted.</p>
<p>Mr Patel explained that high altitudes increase UV radiation levels, with fresh snow able to reflect some 80 per cent of these rays.</p>
<p>This means that sunglasses and ski goggles should be able to block out at least 99 per cent of UVA and UVB light.</p>
<p>When choosing the perfect eyewear for a skiing trip, shoppers should look out for the CE Mark or British Standard BS EN 1836:2005 to ensure adequate protection is provided.    </p>
<p>He continued that sunglasses come in either variable tints, such as transition lenses, or with a filter category number from one to four. In this case four is the darkest lens.</p>
<p>&quot;Category four is suitable for exceptionally sunny conditions such as skiing, but beware, as they are illegal for driving in as they do not allow sufficient light transmission through the lens,&quot; noted the expert.</p>
<p>While many skiers opt for goggles to hit the slopes, sunglasses are a popular alternative.</p>
<p>Furthermore, skiers who prefer wearing goggles for the sport should also pack a pair of sunglasses, for a less chunky alternative for other outdoor activities.</p>
<p>Even cloudy days on the slopes require eye protection, as the reflection of light off snow is still significant.</p>
<p>While some sort of eye protection is clearly important on this type of trip, what style should skiers go for?</p>
<p>Those intending to spend more time sipping hot chocolate in the cosy lodge than out on the slopes should go for bold, designer shades, with oversized frames being a popular option.</p>
<p>People who prefer function over fashion on the other hand need to opt for a pair of shades that will stay on, such as Oakleys.</p>
<p>Posted by Martin Carlin</p>]]></description>
<media:thumbnail url="http://www.website.co.uk/img/Sunglasses-are-important-for-skiers-due-to-the-high-levels-of-UV-radiation-they-are-exposed-to_16000539_800747215_0_0_7047638_300.jpg" height="300" width="203" />
<pubDate>Mon, 03 Oct 2011 16:57:09 +0000</pubDate>
</item>
....
....
</channel>
</rss>

OriginalL'auteur martincarlin87 | 2011-11-29