我正在构建一个关于上传图像和调整大小的项目,目前我们正在使用gem FastImage,这是获取图像url的最佳选择。但我找不到任何Resizing Gem。
我想要什么!
发布于 2017-12-10 14:54:55
我建议你看看载波宝石。它提供您想要的一切,包括调整大小的部分。
您可以通过远程url上传图像如下:
<%= form_for @user, html: { multipart: true } do |f| %>
<p>
<label>My Avatar URL:</label>
<%= image_tag(@user.avatar_url) if @user.avatar? %>
<%= f.text_field :remote_avatar_url %>
</p>
<% end %>或者把它调整成:
class ImageUploader < CarrierWave::Uploader::Base
version :resized do
# returns an image with a maximum width of 100px
# while maintaining the aspect ratio
# 10000 is used to tell CW that the height is free
# and so that it will hit the 100 px width first
process :resize_to_fit => [100, 10000]
end
endhttps://stackoverflow.com/questions/47739230
复制相似问题