简体   繁体   English

如何强制显示 favicon.ico 而不是 favicon.png?

[英]How to force the display of favicon.ico instead of favicon.png?

This is how I have set up the icon-links in my header.这就是我在 header 中设置图标链接的方式。

<link rel="shortcut icon" type="image/x-icon" href="favicon.ico" />
<link rel="apple-touch-icon" href="apple-touch-icon.png">
<link rel="icon" type="image/png" href="/screen/favicon.png" sizes="192x192">

My 16x16 favicon.ico shows a simplified version of my logo, which looks much better than a downscaled version of a larger PNG.我的 16x16 favicon.ico 显示了我的徽标的简化版本,它看起来比较大 PNG 的缩小版本要好得多。 For the touch-icons on mobile devices I have created a 192x192 png of my original logo.对于移动设备上的触摸图标,我创建了一个 192x192 png 的原始徽标。 Since I added that larger PNG to my header, it is not only used (correctly) as a touch-icon, but also replaces the 16x16 favicon.ico.由于我将较大的 PNG 添加到我的 header 中,因此它不仅(正确地)用作触摸图标,而且还取代了 16x16 favicon.ico。 Thus on the browsers the downscaled png-version is display.因此,在浏览器上会显示缩小的 png 版本。 I dislike it, cause the ico-version looks better.我不喜欢它,因为 ico 版本看起来更好。

Is there any way, to force the display of the ico-version of my favicon in browsers?有什么办法可以强制在浏览器中显示我的图标的 ico 版本?

If the reason of your high-resolution image/png icon is Android, then you should declare it via a web manifest .如果您的高分辨率图像/png 图标的原因是 Android,那么您应该通过web 清单声明它。

This is what RealFaviconGenerator does: it only declares low-resolution image/png icons in the HTML.这就是RealFaviconGenerator所做的:它只在 HTML 中声明低分辨率图像/png 图标。 So desktop browsers only pick those, whereas Android get the high resolution icons it expects .所以桌面浏览器只选择那些,而 Android 得到它期望的高分辨率图标 Even if you don't plan to use the service, you can generate a fake set of icons and adapt the generated code and files to your needs.即使您不打算使用该服务,您也可以生成一组假图标,并根据您的需要调整生成的代码和文件。

Full disclosure: I'm the author of this service.完全披露:我是这项服务的作者。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM