danmactough / node-feedparser

Robust RSS, Atom, and RDF feed parsing in Node.js
Other
1.97k stars 192 forks source link

Enclosure with image does not set the image object #212

Closed afanjul closed 7 years ago

afanjul commented 7 years ago

Hi there, I'm working with a RSS 2.0 feed, and I would like to use images in my items, I have used the "enclosure" approach (adding a enclosure tag with the url, type and length) but the image object is not filled.

<item>
    <title><![CDATA[ Test title ]]></title>
    <author>Palbin</author>
    <link>http://palbin.local/es/blog/p21-test-2.html</link>
    <description>
        <![CDATA[...]]>
    </description>
    <pubDate>Tue, 18 Apr 2017 19:54:53 +0200</pubDate>
    <category>General</category>
    <enclosure url="http://www.example.com/example.jpg" type="image/jpeg" length="397088"/>
</item>

Reading the code, in line 891, you set the enclosure array, but after that in line 1046 you dont set the image object unless there is itunes, media, or g_image_link, so...

is it not sufficient enough to add an enclosure with an image url to our items? otherwise if I need another "media/itunes/g_image/etc" tag... what is the enclosure for?

thanks in advance Alex

danmactough commented 7 years ago

@afanjul Currently, we don't interpret enclosures at all. They are just enclosures not, for example, interpreted as "audio" or "video" or "images". I would have no objection to a pull request adding that ability for images, though. I would expect an implementation to use the type attribute of the enclosure. I probably wouldn't use the url as the file suffix is not reliable.