在 Firefox 中加载远程图像

发布于 2025-01-01 05:18:43 字数 1552 浏览 0 评论 0原文

我有一个 HTML 页面。

标记内,src= 指向外部网站:

<img src="http://a.website.com/an_image.jpg" />

在 Firefox 中,图像无法加载。但是,如果我使用 firebug 检查该元素,将鼠标悬停在链接上将显示正确的缩略图(就像 firebug 那样),因此我知道该链接是正确的。

此外,在 Chrome 中,相同的图像可以正常加载。

为什么在 Firefox 中无法加载?

其他可能有用/可能没用的详细信息:

  • 这是一个与开发服务器一起在本地运行的 python Django 应用程序
  • 应用程序:Firefox 9.0.1 (20111228084940)
  • 操作系统:Linux (x86_64-gcc3)

[编辑] 插件:

  • [编辑]插件被删除——不需要它们,问题结果是不同的

[编辑]下面发布的是分别来自 Firefox 和 Chromium 的请求标头:

Firefox:

Accept  image/png,image/*;q=0.8,*/*;q=0.5
Accept-Charset  ISO-8859-1,utf-8;q=0.7,*;q=0.7
Accept-Encoding gzip, deflate
Accept-Language en-gb,it-it;q=0.7,it;q=0.3
Cache-Control   max-age=0
Connection  keep-alive
Host    ia.media-imdb.com
If-Modified-Since   Fri, 03 Sep 2010 17:18:00 GMT
Referer http://127.0.0.1:8001/bulk_action/
User-Agent  Mozilla/5.0 (Ubuntu; X11; Linux x86_64; rv:9.0.1) Gecko/20100101 Firefox/9.0.1

Chromium:

Accept: */ *
Accept-Charset:ISO-8859-1,utf-8;q=0.7,*;q=0.3
Accept-Encoding:gzip,deflate,sdch
Accept-Language:en-GB,en-US;q=0.8,en;q=0.6
Cache-Control:max-age=0
Connection:keep-alive
Host:ia.media-imdb.com
If-Modified-Since:Fri, 03 Sep 2010 17:18:00 GMT
Referer:http://localhost:8001/bulk_action/
User-Agent:Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/535.7 (KHTML, like Gecko) Ubuntu/11.10 Chromium/16.0.912.75 Chrome/16.0.912.75 Safari/535.7

I've got an HTML page.

Inside an <img> tag, the src= points to an external website:

<img src="http://a.website.com/an_image.jpg" />

In firefox, the image doesn't load. However, if I inspect the element with firebug, hovering on the link will show me the correct thumbnail (as firebug does), so I know the link is correct.

Also, in Chrome the same image loads fine.

Why is it not loading in Firefox?

Additional details that may/may not be useful:

  • It's a python Django application running locally with the development server
  • Application: Firefox 9.0.1 (20111228084940)
  • Operating System: Linux (x86_64-gcc3)

[EDIT]
Plugins:

  • [EDIT] Plugins removed -- no need for them, the problem turned out to be different

[EDIT] Posted below are the request headers from Firefox and Chromium respectively:

Firefox:

Accept  image/png,image/*;q=0.8,*/*;q=0.5
Accept-Charset  ISO-8859-1,utf-8;q=0.7,*;q=0.7
Accept-Encoding gzip, deflate
Accept-Language en-gb,it-it;q=0.7,it;q=0.3
Cache-Control   max-age=0
Connection  keep-alive
Host    ia.media-imdb.com
If-Modified-Since   Fri, 03 Sep 2010 17:18:00 GMT
Referer http://127.0.0.1:8001/bulk_action/
User-Agent  Mozilla/5.0 (Ubuntu; X11; Linux x86_64; rv:9.0.1) Gecko/20100101 Firefox/9.0.1

Chromium:

Accept: */ *
Accept-Charset:ISO-8859-1,utf-8;q=0.7,*;q=0.3
Accept-Encoding:gzip,deflate,sdch
Accept-Language:en-GB,en-US;q=0.8,en;q=0.6
Cache-Control:max-age=0
Connection:keep-alive
Host:ia.media-imdb.com
If-Modified-Since:Fri, 03 Sep 2010 17:18:00 GMT
Referer:http://localhost:8001/bulk_action/
User-Agent:Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/535.7 (KHTML, like Gecko) Ubuntu/11.10 Chromium/16.0.912.75 Chrome/16.0.912.75 Safari/535.7

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

孤单情人 2025-01-08 05:18:43

您引用的网站是否允许远程链接?有些网站通过检查引用标头来禁止这样做。完全有可能 Firebug 根本不使用引用者,但 Firefox 在加载页面时会这样做。

在 firebug net 选项卡中,您应该能够看到对图像的请求。检查响应。是 200(http 可以)吗?如果是,发送的数据是正确的还是空白的?

Does the site you refer to allow remote linking? Some sites disallow this by checking the referrer header. It's entirely possible that firebug is not using the referrer at all, but firefox will do it when loading your page.

In the firebug net tab, you should be able to see the request for the image. Check the response for that. Is it a 200 (http ok)? if so, is the data that is sent correct, or is it blank?

等你爱我 2025-01-08 05:18:43

对于遇到此问题并安装了 cookie 拦截器或类似程序的任何人。

我刚才也遇到了这个问题,但事实证明是 Privacy Badger 通过禁用 Trip Advisor cookie 来禁止 Trip Advisor 加载其图像。然而,如果其他人的计算机启用了隐私软件,您就无法阻止这种情况在其他人的计算机上重演。

这是之前和之后的两张屏幕截图。

到到网由于 cookie 拦截器,徽标不可见

允许使用 Cookie 后,Trip Advisor 徽标可见

For anyone that comes across this and has cookie blockers or similar installed.

I had this issue just now as well, but it turned out it was Privacy Badger that was disallowing Trip Advisor to load it's images, by disabling Trip Advisor cookies. However, there is not much you can do to stop this repeating itself on other people's computers if they have privacy software enabled.

Here's two screenshots of before and after.

Trip Advisor logos not visible, due to cookie blocker

Trip Advisor logos visible, after cookies were allowed

っ左 2025-01-08 05:18:43

这是因为 Firefox 中的“自动加载图像”选项被禁用(选项对话框,“内容”面板),在这种情况下,Firefox 将仅加载本地路径的图像,而不加载远程图像。

https://support.mozilla .org/en-US/kb/fix-problems-images-not-show#w_check-image-permissions

This is because the option "Load images automatically" is disabled in your Firefox (option dialog, "Content" panel), in such a case Firefox will only load images with local paths, not remote images.

https://support.mozilla.org/en-US/kb/fix-problems-images-not-show#w_check-image-permissions

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文