diff --git a/app/controllers/media_controller.rb b/app/controllers/media_controller.rb index 6b2de06f36ec355a49f633a69248ec2379dbb5cd..0065ebbb88868a565e8c5b8fce84f4507f251175 100644 --- a/app/controllers/media_controller.rb +++ b/app/controllers/media_controller.rb @@ -5,7 +5,7 @@ class MediaController < ApplicationController def show @size = @blob.byte_size - if @blob.representable? + if @blob.variable? variant_service = VariantService.compute(@blob, params[:filename_with_transformations], params[:format]) transformations = variant_service.transformations if transformations.empty? diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 0acd1311ea2ad0b0fcb76724cf770850fcffaccc..0f7bd945573cc46681ff7774d2e582bd59044551 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -61,4 +61,8 @@ module ApplicationHelper I18nData.languages(I18n.locale)[iso_code.to_s.upcase].titleize end + def default_images_formats_accepted + Rails.application.config.default_images_formats.join(', ') + end + end diff --git a/app/services/importers/hash_to_person.rb b/app/services/importers/hash_to_person.rb index 2b110e2418c62735d5b5c76429542fa0706f4206..273b9394d511ab8ac10f35239ad1781c58d440dc 100644 --- a/app/services/importers/hash_to_person.rb +++ b/app/services/importers/hash_to_person.rb @@ -101,7 +101,7 @@ module Importers def add_picture_if_possible!(person) return if @photo.nil? return if @person.picture.attached? - return unless @photo.end_with?('.jpg') || @photo.end_with?('.png') || @photo.end_with?('.svg') + return unless @photo.end_with?(*Rails.application.config.default_images_formats) begin file = URI.open @photo filename = File.basename @photo diff --git a/app/views/admin/application/featured_image/_edit.html.erb b/app/views/admin/application/featured_image/_edit.html.erb index 775b159544e391888b7c363e78422fb4a6f629ce..2abb7b21d459ef2a338f953c9b97a7610e1ebc6d 100644 --- a/app/views/admin/application/featured_image/_edit.html.erb +++ b/app/views/admin/application/featured_image/_edit.html.erb @@ -3,8 +3,8 @@ as: :single_deletable_file, direct_upload: true, label: false, - hint: '5 Mo max, .jpg, .jpeg, .png, .svg', - input_html: { accept: '.jpg,.jpeg,.png,.svg' }, + hint: t('default_images_hint', formats: default_images_formats_accepted), + input_html: { accept: default_images_formats_accepted }, preview: true, resize: true %> <%= f.input :featured_image_alt, diff --git a/app/views/admin/communication/blocks/components/image/_edit.html.erb b/app/views/admin/communication/blocks/components/image/_edit.html.erb index d82dbabc839cf120ec588aefc234633657f58566..1aa10f55fc0861f0cb6532f09c8556822542e4e9 100644 --- a/app/views/admin/communication/blocks/components/image/_edit.html.erb +++ b/app/views/admin/communication/blocks/components/image/_edit.html.erb @@ -1,7 +1,7 @@ <% label = t('admin.communication.blocks.components.image.input.label') remove = t('admin.communication.blocks.components.image.input.remove') -hint = t('admin.communication.blocks.components.image.input.hint') +hint = t('default_images_hint', formats: default_images_formats_accepted) %> <div class="mb-3"> <div v-if="!<%= model %>.<%= property %>.id"> @@ -11,7 +11,7 @@ hint = t('admin.communication.blocks.components.image.input.hint') </label> <input class="form-control" type="file" - accept="image/*" + accept="<%= default_images_formats_accepted %>" @change="onFileImageChange( $event, <%= model %>, '<%= property %>' )" data-size-limit="<%= Communication::Block::IMAGE_MAX_SIZE %>" :id="<%= dom_id.html_safe %>" diff --git a/app/views/admin/communication/blocks/templates/image/_snippet.html.erb b/app/views/admin/communication/blocks/templates/image/_snippet.html.erb index 98620f0205cd07ae74aff1401ba60ca2c5c6b8d3..61ce1e43fc1eefff24427fa4e26d6e36e4df1c2c 100644 --- a/app/views/admin/communication/blocks/templates/image/_snippet.html.erb +++ b/app/views/admin/communication/blocks/templates/image/_snippet.html.erb @@ -1,6 +1,2 @@ -<% -blob = block.template.image_component.blob -object = blob&.representable? ? blob.representation(resize: 'x180') - : blob -%> -<%= kamifusen_tag object, height: 90, alt: '', class: 'me-2' if object %> +<% blob = block.template.image_component.blob %> +<%= kamifusen_tag blob, height: 90, alt: '', class: 'me-2' if blob %> diff --git a/app/views/admin/communication/blocks/templates/persons/_snippet.html.erb b/app/views/admin/communication/blocks/templates/persons/_snippet.html.erb index 29ecbaa1744a7bd46181f29cd3d683b9817d0e5a..3e0c82046c9de8d7a4f358c8b062474d46d6a40d 100644 --- a/app/views/admin/communication/blocks/templates/persons/_snippet.html.erb +++ b/app/views/admin/communication/blocks/templates/persons/_snippet.html.erb @@ -4,7 +4,7 @@ %> <span class="me-2"> <% if person.best_picture.attached? %> - <%= kamifusen_tag person.best_picture, width: 90, class: 'img-fluid rounded-circle' %> + <%= kamifusen_tag person.best_picture, width: 90, height: 90, class: 'img-fluid rounded-circle' %> <% else %> <%= element.person %> <% end %> diff --git a/app/views/admin/communication/extranets/_form.html.erb b/app/views/admin/communication/extranets/_form.html.erb index 5d1895677ba9aaaf1314ab4a94b85de2b1a0368d..a21c722cf61e7fd5e9e32b14798eca60e28fb3cc 100644 --- a/app/views/admin/communication/extranets/_form.html.erb +++ b/app/views/admin/communication/extranets/_form.html.erb @@ -15,7 +15,8 @@ <%= osuny_panel t('look_feel') do %> <%= f.input :logo, as: :single_deletable_file, - input_html: { accept: '.jpg,.jpeg,.png,.svg' }, + hint: t('default_images_hint', formats: default_images_formats_accepted), + input_html: { accept: default_images_formats_accepted }, preview: 200, direct_upload: true %> <%= f.input :favicon, diff --git a/app/views/admin/communication/websites/agenda/events/_list.html.erb b/app/views/admin/communication/websites/agenda/events/_list.html.erb index 055cea7a999dbc3bf72e8936575c372015b6f52b..98cdcba2140109d1816777ed041a26dd124a47ba 100644 --- a/app/views/admin/communication/websites/agenda/events/_list.html.erb +++ b/app/views/admin/communication/websites/agenda/events/_list.html.erb @@ -20,7 +20,7 @@ </td> <td class="small"><%= render 'admin/communication/websites/agenda/events/dates', event: event %></td> <td> - <%= kamifusen_tag event.featured_image, width: 200 if event.featured_image.attached? %> + <%= kamifusen_tag event.featured_image, width: 100 if event.featured_image.attached? %> </td> </tr> <% end %> diff --git a/app/views/admin/education/schools/_form.html.erb b/app/views/admin/education/schools/_form.html.erb index 90e3d4368a990b38c7ee386b4350f9621bf4e836..1ec5198c7530695bd7e2b913e13c730a6fcca624 100644 --- a/app/views/admin/education/schools/_form.html.erb +++ b/app/views/admin/education/schools/_form.html.erb @@ -20,7 +20,7 @@ <%= f.input :url %> <%= f.input :logo, as: :single_deletable_file, - input_html: { accept: '.jpg,.jpeg,.png,.svg' }, + input_html: { accept: default_images_formats_accepted }, preview: 200, direct_upload: true %> <% end %> diff --git a/app/views/admin/layouts/themes/appstack/_top.html.erb b/app/views/admin/layouts/themes/appstack/_top.html.erb index 075348819eac3c83d4bf0a7d1ca086bff6b31b03..7b66972776b38346821d0b0afb54354adcee085c 100644 --- a/app/views/admin/layouts/themes/appstack/_top.html.erb +++ b/app/views/admin/layouts/themes/appstack/_top.html.erb @@ -22,7 +22,7 @@ <li> <a class="nav-link nav-link--last js-user-button" href="#"> <% if current_user.picture.attached? %> - <%= kamifusen_tag current_user.picture, width: 40, class: 'avatar img-fluid rounded-circle' %> + <%= kamifusen_tag current_user.picture, width: 40, height: 40, class: 'avatar img-fluid rounded-circle' %> <% else %> <%= image_tag 'avatar.jpg', class: 'avatar img-fluid rounded-circle' %> <% end %> diff --git a/app/views/admin/layouts/themes/pure/_nav.html.erb b/app/views/admin/layouts/themes/pure/_nav.html.erb index 0e2edd453709f3da906729d0a26b0553451c8102..5b150ade558568f81efd17871fb5b46d3cf2b11c 100644 --- a/app/views/admin/layouts/themes/pure/_nav.html.erb +++ b/app/views/admin/layouts/themes/pure/_nav.html.erb @@ -45,7 +45,7 @@ context ||= :admin <div class="col-sm-6 col-md-4 col-lg-3"> <%= link_to admin_user_path(current_user) do %> <% if current_user.picture.attached? %> - <%= kamifusen_tag current_user.picture, width: 100, class: 'image' %> + <%= kamifusen_tag current_user.picture, width: 100, height: 100, class: 'image' %> <% else %> <%= image_tag 'avatar.jpg', class: 'image', loading: :lazy %> <% end %> diff --git a/app/views/admin/layouts/themes/pure/_panel.html.erb b/app/views/admin/layouts/themes/pure/_panel.html.erb index a0b5ce45be1cf7798974127fe265a7e1609db670..46f1b88349807e8770184d9d584262d28c010dc3 100644 --- a/app/views/admin/layouts/themes/pure/_panel.html.erb +++ b/app/views/admin/layouts/themes/pure/_panel.html.erb @@ -1,5 +1,5 @@ <section class="pure__section flex-fill position-relative <%= classes %>"> - <%= kamifusen_tag image, class: 'img-fluid mb-3', loading: :lazy if image %> + <%= image_tag image, class: 'img-fluid mb-3', loading: :lazy if image %> <div class="d-lg-flex me-4 <%= 'mb-3' if small %>"> <% if title %> <% if small %> diff --git a/app/views/admin/university/organizations/_form.html.erb b/app/views/admin/university/organizations/_form.html.erb index 5119d876f5de8ae08d3b0ba6ae627271d1397761..290735503f79b9fe5e6b31a12c2585a8d2ae4a1a 100644 --- a/app/views/admin/university/organizations/_form.html.erb +++ b/app/views/admin/university/organizations/_form.html.erb @@ -91,13 +91,13 @@ <%= osuny_panel University::Organization.human_attribute_name('logos') do %> <%= f.input :logo, as: :single_deletable_file, - input_html: { accept: '.jpg,.jpeg,.png,.svg' }, + input_html: { accept: default_images_formats_accepted }, preview: 200, resize: false, direct_upload: true %> <%= f.input :logo_on_dark_background, as: :single_deletable_file, - input_html: { accept: '.jpg,.jpeg,.png,.svg' }, + input_html: { accept: default_images_formats_accepted }, preview: 200, resize: false, direct_upload: true %> diff --git a/app/views/admin/university/people/_form.html.erb b/app/views/admin/university/people/_form.html.erb index 1beeef56ce2f4d5b4ba88639feb1e6e18c3c90fd..157cb8266a211c722151f6ed187ab1db6b4560b6 100644 --- a/app/views/admin/university/people/_form.html.erb +++ b/app/views/admin/university/people/_form.html.erb @@ -114,7 +114,7 @@ <%= f.input :picture, as: :single_deletable_file, label: false, - input_html: { accept: '.jpg,.jpeg,.png,.svg' }, + input_html: { accept: default_images_formats_accepted }, preview: 200, resize: 1, direct_upload: true %> diff --git a/app/views/admin/users/_form.html.erb b/app/views/admin/users/_form.html.erb index ca83eefc3cd3b10f36b4357947ed2692f59a7faf..e00b89b2e2d2252abe79793b78879e73afe7de26 100644 --- a/app/views/admin/users/_form.html.erb +++ b/app/views/admin/users/_form.html.erb @@ -45,7 +45,7 @@ <div class="col-md-4"> <%= f.input :picture, as: :single_deletable_file, - input_html: { accept: '.jpg,.jpeg,.png,.svg' }, + input_html: { accept: default_images_formats_accepted }, preview: 200, resize: 1, direct_upload: true %> diff --git a/app/views/devise/registrations/edit.html.erb b/app/views/devise/registrations/edit.html.erb index b4142762eb6c9467ab611263674dba2b84344433..0120f5a8e0e681578a1696360230a9f32eabb3e8 100644 --- a/app/views/devise/registrations/edit.html.erb +++ b/app/views/devise/registrations/edit.html.erb @@ -36,7 +36,7 @@ <%= f.input :mobile_phone %> <%= f.input :picture, as: :single_deletable_file, - input_html: { accept: '.jpg,.jpeg,.png,.svg' }, + input_html: { accept: default_images_formats_accepted }, preview: 200, resize: 1, direct_upload: true %> diff --git a/app/views/devise/registrations/new.html.erb b/app/views/devise/registrations/new.html.erb index ac997c4163d04e58e50e6d6cb2a4cd94772243e2..e0840a6cbe9824ffce82b3d59961e6910b92c8a8 100644 --- a/app/views/devise/registrations/new.html.erb +++ b/app/views/devise/registrations/new.html.erb @@ -45,7 +45,7 @@ <%= f.input :mobile_phone %> <%= f.input :picture, as: :single_deletable_file, - input_html: { accept: '.jpg,.jpeg,.png,.svg' }, + input_html: { accept: default_images_formats_accepted }, preview: 200, resize: 1, direct_upload: true %> diff --git a/app/views/extranet/account/edit.html.erb b/app/views/extranet/account/edit.html.erb index 1bec66f13cd11f3b3e46d9b1c76db368498b8d66..68ea4442d42e5683edfb31ee619ac3b9e13d8484 100644 --- a/app/views/extranet/account/edit.html.erb +++ b/app/views/extranet/account/edit.html.erb @@ -14,7 +14,7 @@ label_method: lambda { |l| t("languages.#{l.iso_code.to_s}") } %> <%= f.input :picture, as: :single_deletable_file, - input_html: { accept: '.jpg,.jpeg,.png,.svg' }, + input_html: { accept: default_images_formats_accepted }, preview: 200, resize: 1, direct_upload: true %> diff --git a/app/views/extranet/organizations/_form.html.erb b/app/views/extranet/organizations/_form.html.erb index 21d1904fcb3aae321d04ec8d44ba9635165837bf..3dee125b46e5a2c2e9bafdea79a43fbcc1c991a0 100644 --- a/app/views/extranet/organizations/_form.html.erb +++ b/app/views/extranet/organizations/_form.html.erb @@ -75,13 +75,13 @@ <h2><%= University::Organization.human_attribute_name('logos') %></h2> <%= f.input :logo, as: :single_deletable_file, - input_html: { accept: '.jpg,.jpeg,.png,.svg' }, + input_html: { accept: default_images_formats_accepted }, preview: 200, resize: false, direct_upload: true %> <%= f.input :logo_on_dark_background, as: :single_deletable_file, - input_html: { accept: '.jpg,.jpeg,.png,.svg' }, + input_html: { accept: default_images_formats_accepted }, preview: 200, resize: false, direct_upload: true %> diff --git a/app/views/server/application/_top.html.erb b/app/views/server/application/_top.html.erb index adb25cf1f34dc17891111bac69d88085008d5e0a..3d4b125a917e4196858450ff856c30a20437a838 100644 --- a/app/views/server/application/_top.html.erb +++ b/app/views/server/application/_top.html.erb @@ -18,7 +18,7 @@ <li> <a class="nav-link nav-link--last js-user-button" href="#"> <% if current_user.picture.attached? %> - <%= kamifusen_tag current_user.picture, widht: 40, class: 'avatar img-fluid rounded-circle' %> + <%= kamifusen_tag current_user.picture, width: 40, height: 40, class: 'avatar img-fluid rounded-circle' %> <% else %> <%= image_tag 'avatar.jpg', class: 'avatar img-fluid rounded-circle' %> <% end %> diff --git a/app/views/server/universities/_form.html.erb b/app/views/server/universities/_form.html.erb index f8cdb2a5e69ace41075890e86cbbe92d8dff7d03..ddc64561c37ffff14e3b9c6e513d1a8a1405e6f1 100644 --- a/app/views/server/universities/_form.html.erb +++ b/app/views/server/universities/_form.html.erb @@ -27,7 +27,7 @@ <div class="col-md-4"> <%= f.input :logo, as: :single_deletable_file, - input_html: { accept: '.jpg,.jpeg,.png,.svg' }, + input_html: { accept: default_images_formats_accepted }, preview: false, direct_upload: true %> </div> diff --git a/config/application.rb b/config/application.rb index 61e85888512102d76d701355239fd8528a1ba531..56211b00f7252de3bac6846edc79f6c25d99de1e 100644 --- a/config/application.rb +++ b/config/application.rb @@ -61,6 +61,7 @@ module Osuny ] config.allowed_special_chars = '#?!,_@$%^&*+:;£µ-' + config.default_images_formats = ['.jpg', '.jpeg', '.png', '.svg'] config.generators do |g| g.orm :active_record, primary_key_type: :uuid diff --git a/config/locales/communication/contents/en.yml b/config/locales/communication/contents/en.yml index bad502f6fd158edf97cb5abbabc7ca966a120358..648bfb84007f139780f8e23dd3bd0aaf0cda8e09 100644 --- a/config/locales/communication/contents/en.yml +++ b/config/locales/communication/contents/en.yml @@ -33,7 +33,6 @@ en: input: label: Image remove: Remove image - hint: 5 MB max, .png, .jpg, .svg alt: label: Alternative text placeholder: Enter alternative text @@ -203,7 +202,6 @@ en: image: label: Image remove: Remove image - hint: 5 MB max, .png, .jpg, .svg alt: label: Alternative text placeholder: Enter text description diff --git a/config/locales/communication/contents/fr.yml b/config/locales/communication/contents/fr.yml index aa35715c28a165c9aaa9a915ae978071b4ed958c..a16c67cb12bccdd3b96c19ac778bb8217010cec6 100644 --- a/config/locales/communication/contents/fr.yml +++ b/config/locales/communication/contents/fr.yml @@ -33,7 +33,6 @@ fr: input: label: Image remove: Enlever l'image - hint: 5 Mo max, .png, .jpg, .svg alt: label: Texte alternatif placeholder: Entrer la description textuelle @@ -203,7 +202,6 @@ fr: image: label: Image remove: Enlever l'image - hint: 5 Mo max, .png, .jpg, .svg alt: label: Texte alternatif placeholder: Entrer la description textuelle diff --git a/config/locales/communication/en.yml b/config/locales/communication/en.yml index 6cd50c56b90fb6f85137131d9504925fd33d90db..e9dd8b929567816e9909bf0faaa32cdeb9bfcff8 100644 --- a/config/locales/communication/en.yml +++ b/config/locales/communication/en.yml @@ -73,7 +73,7 @@ en: about_type: About color: Couleur cookies_policy: Cookies policy - favicon: Favicon (.png) + favicon: Favicon feature_alumni: Alumni feature_contacts: Directory feature_jobs: Job board @@ -82,7 +82,7 @@ en: has_sso: Has SSO? home_sentence: Sentence displayed on homepage host: Domain - logo: Logo (.png, .jpg, .svg) + logo: Logo name: Name privacy_policy: Privacy policy registration_contact: Contact mail for registrations problems @@ -403,6 +403,7 @@ en: simple_form: hints: communication_extranet: + favicon: '.png file only' host: Sans le protocole sso_button_label: "Default: Sign in via SSO" communication_website: diff --git a/config/locales/communication/fr.yml b/config/locales/communication/fr.yml index a61369e14711f2ba2e070c4b620217ffbce5dcb1..3a129d357b91cf7ddbf95cda0bf921613bfdf37b 100644 --- a/config/locales/communication/fr.yml +++ b/config/locales/communication/fr.yml @@ -73,7 +73,7 @@ fr: about_type: Type d'extranet color: Couleur cookies_policy: Politique de cookies - favicon: Favicon (.png) + favicon: Favicon feature_alumni: Alumni feature_contacts: Annuaire feature_jobs: Offres d'emploi @@ -82,7 +82,7 @@ fr: has_sso: A un SSO ? home_sentence: Phrase affichée sur la home host: Domaine - logo: Logo (.png, .jpg, .svg) + logo: Logo name: Nom privacy_policy: Politique de confidentialité registration_contact: Mail de contact pour les problèmes d'inscription @@ -403,6 +403,7 @@ fr: simple_form: hints: communication_extranet: + favicon: 'Fichier .png uniquement' host: Sans le protocole sso_button_label: "Par défaut : Se connecter en SSO" communication_website: diff --git a/config/locales/en.yml b/config/locales/en.yml index 2ec222ce2816f67d31b392e96de30e8ced569b55..c4d40f270f9cb11cb4df09a1850dcffb47b1863c 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -162,6 +162,7 @@ en: formats: birthday: "%B %d" delete: Delete + default_images_hint: "5 Mb max, %{formats}" devise: failure: invalid: "Invalid email or password." diff --git a/config/locales/fr.yml b/config/locales/fr.yml index c4927504844389b1a77e879e35b5de392bb73b0d..bd8323c6fbace4244be7a38e5e476a9a3fbc8ca5 100644 --- a/config/locales/fr.yml +++ b/config/locales/fr.yml @@ -161,6 +161,7 @@ fr: date: formats: birthday: "%d %B" + default_images_hint: "5 Mo max, %{formats}" delete: Supprimer devise: failure: diff --git a/config/locales/research/en.yml b/config/locales/research/en.yml index 8d19acee493cd0da411c8df079b516d3ed55d1d0..da5bce56385159fd5c8140d435eaac430cca089c 100644 --- a/config/locales/research/en.yml +++ b/config/locales/research/en.yml @@ -131,5 +131,3 @@ en: research_journal_paper: authors_list: Type the authors list directly in this field if you don't want to use the checkboxes above doi: "You can type the DOI identifier without https://, for example “10.19182/perspective/31918â€" - research_journal_volume: - cover: JPG or PNG file diff --git a/config/locales/research/fr.yml b/config/locales/research/fr.yml index 915c14779b6bc92b2ed25f0863bba98e26978a67..bb29775ad7aafef35ced5a073a6f1ac5ab72139f 100644 --- a/config/locales/research/fr.yml +++ b/config/locales/research/fr.yml @@ -130,5 +130,3 @@ fr: research_journal_paper: authors_list: Tapez la liste des auteurs si vous n'utilisez pas les cases à cocher “Auteur·e·s†ci-dessus doi: "Vous pouvez saisir l'identifiant DOI sans https://, par exemple “10.19182/perspective/31918â€" - research_journal_volume: - cover: Fichier JPG ou PNG