Paperclip image url

天涯浪子 提交于 2019-12-17 16:01:31

问题


Stupid question?

<img alt="Phone_large" src="/system/photos/1/small/phone_large.jpg?1238845838" />

Why is "?1238845838" added to the image path?

How can I get my path/url without it?


回答1:


It's commonly referred to as a "cache buster". Paperclip automatically appends the timestamp for the last time the file was updated.

Say you were to remove the cache buster and use /system/photos/1/small/phone_large.jpg instead. The URL wouldn't change when you changed the image and your visitors would see the old image for as long as they had it cached.

If you want to remove it just call .url(:default, timestamp: false). Of course you can change :default to any other style you've defined.

Or if you want to globally default them to off, just put this in a config/initializers/paperclip.rb file.

Paperclip::Attachment.default_options[:use_timestamp] = false


来源:https://stackoverflow.com/questions/3710829/paperclip-image-url

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!