SVG图像不显示在某些Web服务器 [英] SVG images not displaying on certain web servers

查看:1877
本文介绍了SVG图像不显示在某些Web服务器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在某些服务器上显示.SVG我的HTML文件中的图像的问题。这令我感到困惑,因为我认为这是由浏览器决定以图像与否的SVG渲染得到的,但浏览器保持不变。我使用下面的字符串来显示它们:

I'm having issues displaying .svg images within my html files on certain servers. This baffles me as I thought it was dictated by the browser as to whether or not the svg images get rendered, yet the browser remains the same. I'm using the following string to display them:

<img src='path/to/image.svg' alt='image' /> 

在一个RHEL6服务器,它显示,另一个RHEL5服务器上,它不会。的httpd的版本分别为2.2.15-9.el6和2.2.3-53.el5。 Web浏览器一直与谷歌的Chrome 12.0.742.122一致。是否有服务器之间的东西,将决定一个SVG图像是否被渲染?

On one RHEL6 server, it displays, on another RHEL5 server, it will not. The versions of httpd are 2.2.15-9.el6 and 2.2.3-53.el5 respectively. The web browser has remained consistent with Google Chrome 12.0.742.122. Is there something between the servers that will dictate whether or not an svg image gets rendered?

错误日志不报什么,访问日志给.SVG文件的200和304的状态。

Error logs don't report anything, access logs give the .svg files a status of 200 and 304.

推荐答案

SVG图像应该得到送达MIME类型image / SVG + XML的,所以我会建议您检查,第一。查询的MIME类型所服务的一个方法是使用wget来获得图像。下面是wget的输出的一个例子。注意在此它显示MIME类型:

The SVG image should be getting served with MIME type image/svg+xml, so I would recommend checking that first. One way to check the MIME type being served is to use wget to get the image. Here's an example of the output of wget. Note where it displays the MIME type:

jacob@jacob-laptop:~/tmp$ wget http://croczilla.com/bits_and_pieces/svg/samples/butterfly/butterfly.svg
--2011-07-25 11:32:04--  http://croczilla.com/bits_and_pieces/svg/samples/butterfly/butterfly.svg
Resolving croczilla.com... 77.92.68.237
Connecting to croczilla.com|77.92.68.237|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 31187 (30K) [image/svg+xml]
Saving to: `butterfly.svg'

100%[====================================================================>] 31,187      84.5K/s   in 0.4s    

如果MIME类型为image / SVG + XML在这两种情况下,那么我会既差异比较文档的内容,看看是否有它们之间的区别。

If the MIME type is image/svg+xml in both cases, then I would diff the content of both documents to see if there are differences between them.

另外,虽然这并不能回答你的问题,你也应该知道,并不是所有的浏览器使用HTML img标签来渲染SVG支持。这样做的原因是,典型地,IMG标记已经使用比对象或嵌入标签更少安全性。你可以在这里阅读这方面的更多信息:<一href=\"http://stackoverflow.com/questions/4118254/reliably-detecting-img-tag-support-for-svg\">Reliably检测&LT; IMG&GT;对SVG 标签支持

Also, while this does not answer your question, you should also be aware that not all browsers support using an HTML img tag to render SVG. The reason for this is that, typically, img tags have used less security than object or embed tags. You can read here for more info on this: Reliably detecting <img> tag support for SVG

这篇关于SVG图像不显示在某些Web服务器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆