From c995ead1e0a70e49f0d306bdeeb28ab6a3fe898f Mon Sep 17 00:00:00 2001 From: Karina Kwiatek Date: Wed, 22 Dec 2021 16:38:37 +0100 Subject: [PATCH 1/2] Add accept attribute to file inputs --- app/views/settings/_profile.haml | 4 ++-- config/justask.yml.example | 9 +++++++++ 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/app/views/settings/_profile.haml b/app/views/settings/_profile.haml index 6d46c53f..0ddfe141 100644 --- a/app/views/settings/_profile.haml +++ b/app/views/settings/_profile.haml @@ -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 diff --git a/config/justask.yml.example b/config/justask.yml.example index 44990225..2bc33d4d 100644 --- a/config/justask.yml.example +++ b/config/justask.yml.example @@ -59,3 +59,12 @@ hcaptcha: # TOTP Drift period in seconds otp_drift_period: 30 + +accepted_image_formats: + - image/jpeg + - .jpg + - .jpeg + - image/png + - .png + - image/gif + - .gif From a38c134280c87a3b7492cd484d5f14d5b83e4c38 Mon Sep 17 00:00:00 2001 From: Karina Kwiatek Date: Wed, 22 Dec 2021 17:17:48 +0100 Subject: [PATCH 2/2] Add description of `accepted_image_formats` in app config --- config/justask.yml.example | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/config/justask.yml.example b/config/justask.yml.example index 2bc33d4d..1857c52c 100644 --- a/config/justask.yml.example +++ b/config/justask.yml.example @@ -60,6 +60,10 @@ 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