3

For years I've used this neat little unpublished Google service for retrieving favicons from websites.

http://www.google.com/s2/u/0/favicons?domain=stackoverflow.com

This allows me to create icons for <li> tags and such when listing URLs. I was wondering if something existed for Apple touch icons that are becoming more prevalent, especially among major websites.

If not, what would be the most efficient way to retrieve this using PHP?

Here are some examples of icon tags:

<link rel="apple-touch-icon" href="apple-touch-iphone.png" />
<link rel="apple-touch-icon" sizes="72x72" href="apple-touch-ipad.png" />
<link rel="apple-touch-icon" sizes="114x114" href="apple-touch-iphone4.png" />
<link rel="apple-touch-icon" sizes="144x144" href="apple-touch-ipad-retina.png" />

Thanks in advance.

jrue
  • 2,522
  • 4
  • 19
  • 25

1 Answers1

1

Most websites (not all, but most) will hold apple-touch-iphone.png in the root.

A simpler alternative to parsing the HTML via PHP would be to just load domain.com/apple-touch-iphone.png

mrmrw
  • 87
  • 7
  • I would suggest using PHP to verify that the image isn't 404'ed before loading it though, so you don't have links to bad assets on your page. Ideally you might locally cache the icons, so your script doesn't get held up doing this check every time if one of the target servers is slow. – Doktor J Sep 05 '13 at 02:01