Pergunta

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?

Foi útil?

Solução

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.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top