You are not logged in.

Announcement

Support Has Moved!

SimplePie support has moved to Yahoo! Groups, and bug tracking has moved to bugs.simplepie.org. This support site will remain available as a read-only archive for the foreseeable future.

#1 16 June 2006 08:44:27

bm
SimplePie Superstar
Registered: 25 March 2006
Posts: 29

New function: get_feed_favicon()

Example code:

Code:

<?php echo $feed->get_feed_link(); ?>"><?php echo $feed->get_feed_favicon(); ?></a>

Example output:

http://www.bioneural.net/favicon.ico Too much pie could kill you, by...
http://simplepie.org/favicon.ico SimplePie could save your life, by...

Needs some CSS but you could make a pretty list, combining feeds from several sites to show the post, with a favicon for attribution.

Waddaya think?

Offline

 

#2 16 June 2006 10:41:14

Skyzyx
Creator and Co-Developer
From: Silicon Valley, CA, USA
Registered: 30 January 2006
Posts: 1567
Website

Re: New function: get_feed_favicon()

That's a good idea.  That information isn't in the feed though.   Hmmm, we could:

1) Figure out where the feed is _really_ coming from (feedburner can be a problem, although SP already resolves the feed's real URL)

2) Figure out the domain name, and look for /favicon.ico.  If it exists, cache it (since it's not likely to change often).

3) If the domain name is a subdomain, and no favicon exists, move up one subdomain, and look again (rss.xml.domain.com -> xml.domain.com -> domain.com).

4) Cache filename will be a md5'd version of the feed's domain name, to make it easy (and faster) for SimplePie to retrieve it.

This will probably go into 1.1 (since we're pretty much closed on 1.0 features).


SimplePie 1.0 | Trunk Demo | SimplePie Twitter | My Twitter | My LinkedIn

I'm currently working 2 full-time jobs, plus SimplePie. Responses will be lighter until February-ish 2008, but I expect to be available 1-2 times a week to answer questions. To get responses faster, try our IRC chat. irc://irc.freenode.net/simplepie. You must have an IRC client installed.

Offline

 

#3 17 June 2006 07:16:41

bm
SimplePie Superstar
Registered: 25 March 2006
Posts: 29

Re: New function: get_feed_favicon()

Maybe this sort of PHP script would do it. This particular one won't work for me on DreamHost, since they block fopen.

Offline

 

#4 17 June 2006 14:14:04

bm
SimplePie Superstar
Registered: 25 March 2006
Posts: 29

Re: New function: get_feed_favicon()

Actually this does work:

Code:

<img src="<?php echo $feed->get_feed_link(); ?>/favicon.ico" alt="favicon" />

Returns:

Code:

<img src="http://www.bioneural.net/favicon.ico" alt="favicon" />

I have it working in a WordPress template page here.

P.S. The author of the script in my previous post replied to my email, saying "What the code does is, given a URL, it figures out the favicon for that URL and returns the URL for the favicon. It doesn't actually download the favicon, it just checks for its existence and returns the URL on success. The URL can then be placed in your HTML." Sounds perfect, no?

Offline

 

#5 18 June 2006 10:18:36

Skyzyx
Creator and Co-Developer
From: Silicon Valley, CA, USA
Registered: 30 January 2006
Posts: 1567
Website

Re: New function: get_feed_favicon()

Pretty close, yeah! smile


SimplePie 1.0 | Trunk Demo | SimplePie Twitter | My Twitter | My LinkedIn

I'm currently working 2 full-time jobs, plus SimplePie. Responses will be lighter until February-ish 2008, but I expect to be available 1-2 times a week to answer questions. To get responses faster, try our IRC chat. irc://irc.freenode.net/simplepie. You must have an IRC client installed.

Offline

 

#6 19 June 2006 07:50:31

Malaiac
Member
Registered: 17 April 2006
Posts: 15
Website

Re: New function: get_feed_favicon()

I have the code to find the source URL from the Google News feed :

Code:

$link = urldecode($item->get_permalink()); 
$id = substr(substr($link,strpos($link, 'http://',10)),0,strrpos(substr($link,strpos($link, 'http://',10)), 'cid')-1); }

(I use it to remove duplicates... the visitor only sees and click the redirected-by-Gnews URL)

Offline

 

#7 19 June 2006 09:25:02

Skyzyx
Creator and Co-Developer
From: Silicon Valley, CA, USA
Registered: 30 January 2006
Posts: 1567
Website

Re: New function: get_feed_favicon()

There's already a function in SP that resolves the true feed home.  Checking the local subdomain first (if any), and moving up the domain chain would be the most effective way of grabbing a favicon.

We've just decided to do a Beta 3 instead of a B2, Bugfix 1, so this will be wrapped into that release, probably as the both of you have described above.  We'll likely go a bit more in-depth for the 1.0 release.


SimplePie 1.0 | Trunk Demo | SimplePie Twitter | My Twitter | My LinkedIn

I'm currently working 2 full-time jobs, plus SimplePie. Responses will be lighter until February-ish 2008, but I expect to be available 1-2 times a week to answer questions. To get responses faster, try our IRC chat. irc://irc.freenode.net/simplepie. You must have an IRC client installed.

Offline

 

#8 19 June 2006 09:36:52

Malaiac
Member
Registered: 17 April 2006
Posts: 15
Website

Re: New function: get_feed_favicon()

I'm not talking about feed home, but item home from the feed
like in :
http://simplepie.org/demo/?feed=http:// … t=rss#feed
Item links are : "http://news.google.com/news/url?sa=T&ct=us/3-2-0&fd=R&url=http://www.columbusdispatch.com/news-story.php%3Fstory%3D193794&cid=1107371944&ei=cNKWRIrvFoKuoQLOnIyOBg"

The code above return "http://www.columbusdispatch.com/news-story.php%3Fstory%3D193794"

Is there a function like this in SP ? 80

Last edited by Malaiac (19 June 2006 09:37:37)

Offline

 

#9 20 June 2006 20:30:46

Skyzyx
Creator and Co-Developer
From: Silicon Valley, CA, USA
Registered: 30 January 2006
Posts: 1567
Website

Re: New function: get_feed_favicon()

No, there's not.  It would most likely pull the favicon for google news, but not the other site.


SimplePie 1.0 | Trunk Demo | SimplePie Twitter | My Twitter | My LinkedIn

I'm currently working 2 full-time jobs, plus SimplePie. Responses will be lighter until February-ish 2008, but I expect to be available 1-2 times a week to answer questions. To get responses faster, try our IRC chat. irc://irc.freenode.net/simplepie. You must have an IRC client installed.

Offline

 

#10 2 July 2006 01:18:36

bm
SimplePie Superstar
Registered: 25 March 2006
Posts: 29

Re: New function: get_feed_favicon()

FYI, I found and acceptable cosmetic fix for missing favicons in Firefox (see the "desert" section) that show as an ugly "X" with:

Code:

<img src="' . $feed->get_feed_link() . '/favicon.ico" alt="X" width="16" height="16" />

Offline

 

Board footer

Powered by PunBB
© Copyright 2002–2005 Rickard Andersson