RSS with images

Discussion in 'Subrion CMS Plugins Discussion' started by DNadel, Nov 7, 2012.

  1. DNadel

    DNadel New Member

    Is it possible to get RSS images using the RSS reader? I haven't been able to figure it out. For instance, I put into the Manage RSS menu, but it prints out only the title and link. In a regular RSS reader program, this same link produces an image and a description as well.
    I was able to make the description appear by going into the files and adding {$item.description} into plugins/rss_reader/templates/front/index.tpl, but I can't figure out how to make it display out the image. Anyone able to offer some help here?
    Last edited: Nov 7, 2012
  2. Vasily_B.

    Vasily_B. Project Manager

    Hi and welcome!

    I've rechecked the structure of their response, and here is what they return:
    Code (Text):

    <?xml version="1.0" encoding="UTF-8"?>

    <?xml-stylesheet href="/externalflash/NASA_Detail/NASA_Detail.xsl" type="text/xsl"?>

    <rss version="2.0">
        <title>NASA Image of the Day (Large)</title>
        <description>The latest NASA "Image of the Day" - Large Version.</description>
        <managingEditor>[email protected]</managingEditor>
        <webMaster>[email protected]</webMaster>
        <image xmlns:java_code="xalan://">
            <title>Election Day 2012</title>
            <link> [url=]NASA - NASA Featured Images and Galleries[/url] </link>

        <item xmlns:java_code="xalan://">
            <title>Election Day 2012</title>
            <guid isPermaLink="true"></guid>
            <description>The American flag patch pictured here is from the left arm on Neil Armstrong's Apollo 11 suit. This image was taken in April 2006 at the National Air and Space Museum's Garber Facility in Suitland, Md. NASA astronauts Leroy Chiao, Edward Michael Fincke and Greg Chamitoff have all voted while aboard the International Space Station thanks to a bill passed in 1997 by Texas legislatures. The bill sets up a technical procedure for astronauts -- nearly all of whom live in Houston -- to vote from space. Current station Commander Suni Williams, a resident of Florida, voted via absentee ballot before departing for her duties as part of Expedition 32 on the International Space Station. Image Credit: NASA</description>
            <pubDate>Tue, 06 Nov 2012 00:00:00 EST</pubDate>
            <enclosure length="1234567" type="image/jpeg" url=""/>
    In order to display images you'll need to modify the rss2array function, but I suppose it could be incompatible with other URLs if you do that :((

    You can see the value of array you get if you print it in includes/rss2array/rss2array.php file.

    just add this code:

    _v($tmp); die();
    $tmp = rss2array($url);
  3. DNadel

    DNadel New Member

    Thanks for the quick reply!

    Unfortunately I think I might be working with an older version, the line you referenced isn't in the rss2array file. Also I'm not too sure that that file does anything at all, since the program seems to run the same even if I remove it entirely...

    So it's not such a simple fix then. I had thought that the program was supposed to handle images because of the 'if ($name == "IMAGE")' line. Is there a variable that points toward image-type objects?
  4. Vasily_B.

    Vasily_B. Project Manager

    it seems the file is really obsolete :( I've checked its specification and here is what I found:
    The feed you are using tries to use RSS 2.0 standard. Unfortunately that lib does not work with it, but you can use this one instead:
    Download Last RSS | Last RSS

    Simply include this file and use its methods to fetch data. Let us know if you need any assistance.
  5. smnetworks

    smnetworks New Member

    Just wondering if anyone found out how to get images from the RSS Feed?

    I came up with this script to place Subrion feeds on other pages like

    Draft Code
    Code (Text):

    .feed {width:500px; font:11pt arial;}
    .feed a{color:blue}
    .h3 {color:#F63;
    font-family:Arial, Helvetica, sans-serif;

    <div class="feed">  
    //---Code to display RSS feeds using MagpieRSS
    include "magpierss/";  //include the magpierss script

    define('MAGPIECACHEDIR', '/tmp/magpie_cache');
    $url = '';  //this is the url of the feed, enter your own url here
    $rss = fetch_rss( $url );
    $items = array_slice($rss->items, 0, 5);
    foreach ($items as $item) {
        $href = $item['guid'];
        $title = $item['title'];
        $desc = substr($item['description'],0,124)."...";
        echo '<h3 class="h3"><a href='. $href . '>' . $item['title'] . '</a></h3>' . $desc .
        '<a href='. $href . '><img src="health-news/templates/nutrientcor/img/info.png" alt="' . $title . '"></a>' .
        ' <a href='. $href . '>Read More</a>';


Share This Page