Merge pull request #221 from Retrospring/feature/file-input-accept-attr

Add accept attribute to file inputs
This commit is contained in:
Karina Kwiatek 2021-12-22 19:57:43 +01:00 committed by GitHub
commit fcd7217126
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 15 additions and 2 deletions

View File

@ -8,7 +8,7 @@
.pull-left
%img.avatar-lg.mr-3{ src: current_user.profile_picture.url(:medium) }
.media-body
= f.file_field :profile_picture, label: t('views.settings.profile.avatar')
= f.file_field :profile_picture, label: t('views.settings.profile.avatar'), accept: APP_CONFIG[:accepted_image_formats].join(',')
.row#profile-picture-crop-controls{ style: 'display: none;' }
.col-sm-10.col-md-8
@ -25,7 +25,7 @@
.col
%img.mw-100.mr-3{ src: current_user.profile_header.url(:mobile) }
.col-xs-12.mt-3.mt-sm-0.pl-3.pr-3
= f.file_field :profile_header, label: t('views.settings.profile.header')
= f.file_field :profile_header, label: t('views.settings.profile.header'), accept: APP_CONFIG[:accepted_image_formats].join(',')
.row#profile-header-crop-controls{ style: 'display: none;' }
.col-sm-10.col-md-8

View File

@ -59,3 +59,16 @@ hcaptcha:
# TOTP Drift period in seconds
otp_drift_period: 30
# This list controls the "accept" attribute on file upload fields
# This ensures mobile users get an appropriate file picker (one for only images)
# as well as preventing the upload of videos or formats we don't support
# including making iOS automatically convert HEIC files to JPEG
accepted_image_formats:
- image/jpeg
- .jpg
- .jpeg
- image/png
- .png
- image/gif
- .gif