如何检查图像版本是否存在但不在载波中 rails
How to check image version exists od not in carrierwave rails
有些图片有手机版,有些没有。我想检查是否存在移动版本
我用过
image.mobile.file.exists?
但它也报错
NoMethodError: undefined method `mobile' for
我该如何检查?
您的上传程序中没有定义名为 'mobile' 的图像版本。
如果您调用了上传器 ImageUploader,请打开 app/uploaders/image_uploader.rb
将以下版本添加到文件中:
version :mobile do
process resize_to_fill: [620, 270]
end
根据需要交换 x 和 y 尺寸。在此之后,所有新图像都将具有可用的 'mobile' 属性。如果您希望它适用于所有旧图像,那么您需要保存它们,新版本才可用。
有些图片有手机版,有些没有。我想检查是否存在移动版本
我用过
image.mobile.file.exists?
但它也报错
NoMethodError: undefined method `mobile' for
我该如何检查?
您的上传程序中没有定义名为 'mobile' 的图像版本。
如果您调用了上传器 ImageUploader,请打开 app/uploaders/image_uploader.rb
将以下版本添加到文件中:
version :mobile do
process resize_to_fill: [620, 270]
end
根据需要交换 x 和 y 尺寸。在此之后,所有新图像都将具有可用的 'mobile' 属性。如果您希望它适用于所有旧图像,那么您需要保存它们,新版本才可用。