I would like to provide the user of my android app a preview of each article given to them by an RSS feed. Since the user enters the URL of the site with the RSS feed I don not control the source of the RSS (I must assume the page is using the RSS 2 specifications).
I know there is an <image>
tag for the channel RSS feed but how do I get a preview image for each article?
In contemplating this problem I have considered parsing through the website and finding an <img>
tag and using that… but the possibility of selecting an add or irrelevant image is high.
Right now I am doing all my XML parsing on a server to remove the restriction of phone processing – so parsing for the image would be easy-ish… but not fun 🙂
Any Ideas? (I’m thinking something like how Facebook adds thumbnails to your posts – I’ve looked into Facebook’s open graph – but it is not widely enough distributed to be of any use)
There’s no easy answer here. The RSS spec doesn’t have a field for a thumbnail preview that I’m aware of.
The Media RSS spec does define a
<media:thumbnails>
element, but that’s neither widely used nor really what you’re looking for.I’d use the
<image>
tag first, if it’s present. If it’s not, then you can scan through the article and find an<img>
tag if it’s present — but you’re right, it might not be the correct one. To compensate for that, you could filter out known ad sizes, then select the largest image on the page.In all cases, you’ll want to resize the image to be thumbnail sized. This is application dependent behavior.