Currently when I store any image using shrine uploader then I received url :-
/uploads/store/90bcb5a78ed5de16a6c62eea1fb80ed1.png
but I want url to be display like:-
/uploads/store/original_image_name.png
is there any solution
for reference:-
initializer/shrine.rb
require "shrine/storage/file_system"
Shrine.storages = {
cache: Shrine::Storage::FileSystem.new("public", prefix: "uploads/cache"),
store: Shrine::Storage::FileSystem.new("public", prefix: "uploads/store")
}
model/image_uploader.rb
class ImageUploader < Shrine
plugin :derivatives
plugin :url_options, store: { host: "www.cloudfair.com" }
Attacher.derivatives_processor do |original|
processor = ImageProcessing::MiniMagick.source(original)
{
large: processor.resize_to_limit!(1280, 800),
medium: processor.resize_to_limit!(600, 600),
small: processor.resize_to_limit!(400, 400),
}
end
end
to upload image:-
photo = Photo.new
photo.image = params[:image_file]
photo.image_derivative!
photo.save()
to access image URL:-
photo.image(:small).url