Set constraints for images in uploader
This commit is contained in:
parent
acf9595d71
commit
a70b967919
|
@ -11,9 +11,11 @@ class BaseUploader < CarrierWave::Uploader::Base
|
|||
# Process cropping on upload
|
||||
process :cropping
|
||||
|
||||
def store_dir
|
||||
"/uploads/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}"
|
||||
end
|
||||
def content_type_whitelist = %w[image/jpeg image/gif image/png]
|
||||
|
||||
def store_dir = "/uploads/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}"
|
||||
|
||||
def size_range = (1.byte)..(2.megabytes)
|
||||
|
||||
def paperclip_path
|
||||
return "/users/:attachment/:id_partition/:style/:basename.:extension" if APP_CONFIG["fog"].blank?
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
.flex-shrink-0
|
||||
= render AvatarComponent.new(user: current_user, size: "lg", classes: ["me-3"])
|
||||
.flex-grow-1
|
||||
= f.file_field :profile_picture, accept: APP_CONFIG[:accepted_image_formats].join(","), data: { cropper_target: "input", action: "cropper#change" }
|
||||
= f.file_field :profile_picture, accept: current_user.profile_picture.content_type_whitelist.join(','), data: { cropper_target: "input", action: "cropper#change" }
|
||||
|
||||
.row.d-none{ data: { cropper_target: "controls" } }
|
||||
.col-sm-10.col-md-8
|
||||
|
@ -22,7 +22,7 @@
|
|||
.col-xs-12.col-md-6
|
||||
%img.mw-100.me-3{ src: current_user.profile_header.url(:mobile) }
|
||||
.col-xs-12.col-md-6.mt-3.mt-sm-0.ps-3.pe-3
|
||||
= f.file_field :profile_header, accept: APP_CONFIG[:accepted_image_formats].join(","), data: { cropper_target: "input", action: "cropper#change" }
|
||||
= f.file_field :profile_header, accept: current_user.profile_header.content_type_whitelist.join(','), data: { cropper_target: "input", action: "cropper#change" }
|
||||
|
||||
.row.d-none{ data: { cropper_target: "controls" } }
|
||||
.col-sm-10.col-md-8
|
||||
|
|
Loading…
Reference in New Issue