Spedwards
Spedwards

Reputation: 4492

Set the favicon on a non HTML page

I'm using PHP to display an image (dynamically returning a binary blob with a mime type of image/png for example) so that means I can't use the typical method for changing the favicon (link tags).

The HTML solution is this:

<link rel="shortcut icon" href="favicon.ico" />

Is there a way I can set the favicon in PHP for a non HTML document?

Upvotes: 2

Views: 531

Answers (1)

Brandon - Free Palestine
Brandon - Free Palestine

Reputation: 16656

Most browsers will default to looking for a favicon in the root directory like so: http://example.com/favicon.ico. You can use this for a favicon for your images.

If you want different favicons for each image, that's simply not possible (browsers provide no mechanism for this). There is a proposed standard for setting favicons via HTTP headers (RFC 5988) but it's still a draft and hasn't been implemented by browser vendors.

Upvotes: 6

Related Questions