Chrome会下载PNG图片链接。我希望他们打开以便在新标签中查看。我如何让Chrome做到这一点?

时间:2023-01-13 10:12:49

When I click on an image link right now, Chrome downloads the image instead of opening it.

当我立即点击图片链接时,Chrome会下载图片而不是打开图片。

Even if I right-click and select Open link in new tab Chrome still downloads the image, and I have to go through the extra steps of opening the file for viewing manually.

即使我右键单击并选择在新标签页中打开链接,Chrome仍会下载图像,我必须完成打开文件以便手动查看的额外步骤。

This feels like a mime-type issue to me, but why would Chrome not recognize "image/png" as a valid mime-type for viewing? All PNG images display just fine in an HTML page.

这对我来说就像是一个哑剧类型的问题,但为什么Chrome不会将“image / png”识别为有效的mime类型以供查看?所有PNG图像在HTML页面中都可以正常显示。

This feels like a really stupid question, but I have googled and searched all over and can't get close to an answer. Am I the only one in the world who has this problem?

这感觉就像一个非常愚蠢的问题,但我搜索了所有搜索并且无法接近答案。我是世界上唯一一个有这个问题的人吗?

NOTE: This only happens for PNG images.

注意:这仅适用于PNG图像。

3 个解决方案

#1


16  

The web server is probably serving the image using the image/x-png MIME type. Chrome does not recognise this as an image (as of August 2012 February 2013), hence offers the file as a download.

Web服务器可能使用image / x-png MIME类型提供图像。 Chrome无法将其识别为图像(截至2012年8月,2013年2月),因此可以下载该文件。

image/x-png is a legacy MIME type from the days before it got its official name, image/png, in 1996. However, when Internet Explorer uploads an image it does so using image/x-png "for backward compatibility". I believe this was the case up to IE8, and was "fixed" in IE9. If the web server does not correctly handle this (the web server should detect this non-standard MIME type and treat it as image/png), then it may serve up the client-provided MIME type to other users, including to Google Chrome. Additionally, some web sites will serve up all PNGs as image/x-png.

image / x-png是1996年获得正式名称image / png之前的传统MIME类型。但是,当Internet Explorer上传图像时,它使用image / x-png“向后兼容”。我相信这是IE8的情况,并且在IE9中被“修复”了。如果Web服务器未正确处理此问题(Web服务器应检测此非标准MIME类型并将其视为image / png),则它可能会将客户端提供的MIME类型提供给其他用户,包括Google Chrome。此外,一些网站将提供所有PNG作为image / x-png。

If you're the web developer you should detect incoming image/x-png and treat it as image-png (never serve up image/x-png).

如果您是Web开发人员,则应检测传入的image / x-png并将其视为image-png(从不提供image / x-png)。

If you're the user report it as a bug and see @kriegaex's answer for a workaround.

如果您是用户将其报告为错误,请参阅@ kriegaex的答案以获得解决方法。

#2


15  

@Tom Clift is right, and here is my workaround for it: use Chrome extension Redirector and add a rule replacing the Content-Type header. That's it. :-)

@Tom Clift是对的,这是我的解决方法:使用Chrome扩展重定向器并添加替换Content-Type标头的规则。而已。 :-)

#3


0  

When you right click on the image you need to select then 'Open image in new Tab' from the drop down and NOT 'Open link in new tab' this will then open the image in a new tab.

当您右键单击图像时,您需要从下拉菜单中选择“在新标签页中打开图像”而不是“在新标签页中打开链接”,然后在新标签页中打开图像。

#1


16  

The web server is probably serving the image using the image/x-png MIME type. Chrome does not recognise this as an image (as of August 2012 February 2013), hence offers the file as a download.

Web服务器可能使用image / x-png MIME类型提供图像。 Chrome无法将其识别为图像(截至2012年8月,2013年2月),因此可以下载该文件。

image/x-png is a legacy MIME type from the days before it got its official name, image/png, in 1996. However, when Internet Explorer uploads an image it does so using image/x-png "for backward compatibility". I believe this was the case up to IE8, and was "fixed" in IE9. If the web server does not correctly handle this (the web server should detect this non-standard MIME type and treat it as image/png), then it may serve up the client-provided MIME type to other users, including to Google Chrome. Additionally, some web sites will serve up all PNGs as image/x-png.

image / x-png是1996年获得正式名称image / png之前的传统MIME类型。但是,当Internet Explorer上传图像时,它使用image / x-png“向后兼容”。我相信这是IE8的情况,并且在IE9中被“修复”了。如果Web服务器未正确处理此问题(Web服务器应检测此非标准MIME类型并将其视为image / png),则它可能会将客户端提供的MIME类型提供给其他用户,包括Google Chrome。此外,一些网站将提供所有PNG作为image / x-png。

If you're the web developer you should detect incoming image/x-png and treat it as image-png (never serve up image/x-png).

如果您是Web开发人员,则应检测传入的image / x-png并将其视为image-png(从不提供image / x-png)。

If you're the user report it as a bug and see @kriegaex's answer for a workaround.

如果您是用户将其报告为错误,请参阅@ kriegaex的答案以获得解决方法。

#2


15  

@Tom Clift is right, and here is my workaround for it: use Chrome extension Redirector and add a rule replacing the Content-Type header. That's it. :-)

@Tom Clift是对的,这是我的解决方法:使用Chrome扩展重定向器并添加替换Content-Type标头的规则。而已。 :-)

#3


0  

When you right click on the image you need to select then 'Open image in new Tab' from the drop down and NOT 'Open link in new tab' this will then open the image in a new tab.

当您右键单击图像时,您需要从下拉菜单中选择“在新标签页中打开图像”而不是“在新标签页中打开链接”,然后在新标签页中打开图像。