繁体   English   中英

Retina.js 为每个图像 @2x.png 产生 404 错误

[英]retina.js produces 404 errors for every image @2x.png

我正在我的网站上运行retina.js,因为越来越多的人正在使用视网膜显示器,因此从长远来看这对我有好处。 但显然,retina.js 会扫描所有图像的根目录并在其末尾附加一个@2x.png 但它并没有真正再现图像本身。 所以当浏览器去寻找它时。 什么都没有,Nada,Zilch,NO-Can-Do。

坦率地说,我不知道retina.js 是否真的值得麻烦,或者404s 是否也值得担心。 但作为一名 UI/UX 工程师,强迫症正在吞噬我。 哈哈。

无论如何,这是一个已知问题吗? 是否有不包括手动复制图像并将它们加载到服务器的 jquery/javascript 解决方法? 那会很麻烦。

我希望我可以向您展示一些代码,但我可以在这里分享什么? 我的<head>中对 Retina.js 的引用?:)

这是显示罪魁祸首的开发工具

在此处输入图像描述

谢谢

将此添加到 .htaccess

This is to short circuit non existent Retina image requests generated by retina.js

without this, the whole wordpress 404 stack will be executed which is very expensive

We simply redirect the request to the non @2x version of the file, if one exists, otherwise, send a 404 status    
  <IfModule rewrite_module>
    RewriteEngine on
    RewriteBase /
    RewriteCond %{REQUEST_FILENAME} @2x\.[a-z]+$
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^(.*)@2x(.*)$ $1$2 [E=NORETINA:1]
    RewriteCond %{ENV:NORETINA} 1
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule .* - [L,R=404]
 </IfModule>

暂无
暂无

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

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