本文介绍了Rails资产管道视网膜@ 2x和缓存破坏者时间戳不一致的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

retina.js查找具有相同文件名但文件扩展名前带有@ 2x的图像

retina.js looks for an image with the same filename but with @2x before the file extension

Rails资产管道在文件名的末尾添加了一个缓存清除时间戳记

The rails asset pipeline adds a cache busting timestamp to the end of the filename

这意味着retina.js正在寻找[email protected],但文件位于[email protected]

This means retina.js is looking for [email protected] but the file is at [email protected]

有人为此解决吗?

这是谁的错误,即如果原始文件名匹配指示其具有缓存无效哈希的模式,或者应该更改rails管道以确保@,则应培训retina.js在[email protected]处查找文件. 2x总是在文件扩展名之前吗?

Who's wrong on this ie, should retina.js be trained to look for files at [email protected] if the original filename matches a pattern that indicates it has a cache busting hash, or should the rails pipeline be changed to ensure the @2x is always just before the file extension?

推荐答案

这似乎需要一些工作,但看起来正确的方法是:

This seems like a bit of work around in and of itself but looks like the correct way to do this is:

<%= image_tag('image', retina: true) %>

这将添加retina.js将使用的正确的data-at2x属性

and this will add the correct data-at2x attribute that retina.js will pick up

这篇关于Rails资产管道视网膜@ 2x和缓存破坏者时间戳不一致的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-22 02:04