diff --git a/app/models/communication/block.rb b/app/models/communication/block.rb index 4b28873c1a4834582c1efc271a31a59cc3bfbd95..29f0ef5cf08814656a2bb7a7c78b0d15db1566fc 100644 --- a/app/models/communication/block.rb +++ b/app/models/communication/block.rb @@ -29,6 +29,7 @@ class Communication::Block < ApplicationRecord include Accessible IMAGE_MAX_SIZE = 5.megabytes + FILE_MAX_SIZE = 100.megabytes belongs_to :about, polymorphic: true diff --git a/app/models/communication/website/post.rb b/app/models/communication/website/post.rb index 1c2838ed8b6169547f007ade72c4c48cdcaedadf..e81056ab8e7f3ef8cb8ed10b115401719048f1db 100644 --- a/app/models/communication/website/post.rb +++ b/app/models/communication/website/post.rb @@ -138,7 +138,7 @@ class Communication::Website::Post < ApplicationRecord return if website.url.blank? return if website.special_page(Communication::Website::Page::CommunicationPost)&.path.blank? return if current_permalink_in_website(website).blank? - Static.clean_path "#{website.url}#{current_permalink_in_website(website).path}" + "#{Static.remove_trailing_slash website.url}#{Static.clean_path current_permalink_in_website(website).path}" end def to_s diff --git a/app/views/admin/communication/blocks/components/file/_edit.html.erb b/app/views/admin/communication/blocks/components/file/_edit.html.erb index 52971a54e0e37ff8c0b443462c306c2aafd60907..9b5ddb9c6e59ecba5945637e57f53e7c155106c1 100644 --- a/app/views/admin/communication/blocks/components/file/_edit.html.erb +++ b/app/views/admin/communication/blocks/components/file/_edit.html.erb @@ -12,6 +12,7 @@ remove = t 'admin.communication.blocks.components.file.input.remove' type="file" accept="*" @change="onFileImageChange( $event, <%= model %>, '<%= property %>' )" + data-size-limit="<%= Communication::Block::FILE_MAX_SIZE %>" :id="<%= dom_id.html_safe %>"> </div> <div v-if="<%= model %>.<%= property %>.id"> diff --git a/app/views/admin/communication/blocks/edit.html.erb b/app/views/admin/communication/blocks/edit.html.erb index ff00edca28c92593efb9487ff188bb22638ef168..f0d54ec57409a5b3804d21b453925d1e4bad8478 100644 --- a/app/views/admin/communication/blocks/edit.html.erb +++ b/app/views/admin/communication/blocks/edit.html.erb @@ -68,10 +68,17 @@ this.uploadFile(event.target, files[0], object, key); }, uploadFile(input, file, object, key) { - var size = Math.round(file.size / 1024 / 1024); - var controller = new Vue.DirectUploadController(input, file, this.directUpload.url) - if (file.size > <%= Communication::Block::IMAGE_MAX_SIZE %>) { - alert("<%= t('admin.communication.blocks.alerts.image_is_too_big').html_safe %> (" + size + " Mo > <%= number_to_human_size Communication::Block::IMAGE_MAX_SIZE %>)"); + var size = Math.round(file.size / 1024 / 1024), + sizeLimit = <%= Communication::Block::IMAGE_MAX_SIZE %>, + sizeLimitMo = 0, + controller; + if (input.hasAttribute('data-size-limit')) { + sizeLimit = input.getAttribute('data-size-limit'); + } + sizeLimitMo = Math.round(sizeLimit / 1024 / 1024); + controller = new Vue.DirectUploadController(input, file, this.directUpload.url); + if (file.size > sizeLimit) { + alert("<%= t('admin.communication.blocks.alerts.file_is_too_big').html_safe %> (" + size + " Mo > " + sizeLimitMo + " Mo)"); return; } controller.start(function (blob) { diff --git a/app/views/admin/communication/unsplash/_selector.html.erb b/app/views/admin/communication/unsplash/_selector.html.erb index 5974eb5f6e18a9b99953f65fc6f7b954b08641d9..93de143eef4042fe5d188ad450d8f0ddac98c6dd 100644 --- a/app/views/admin/communication/unsplash/_selector.html.erb +++ b/app/views/admin/communication/unsplash/_selector.html.erb @@ -194,7 +194,6 @@ path = admin_communication_unsplash_path(website_id: nil, format: :json) inputImage.setAttribute('src', image.preview); inputImageContainer.parentElement.classList.add('sdfi-deletable-file--with-file'); - inputAlt.value = image.alt; $(inputCredit).summernote('code', image.credit); this.modal.hide(); } diff --git a/config/locales/communication/en.yml b/config/locales/communication/en.yml index b532a9d82f429591b2233b7cde66f828ef388203..31032486bb73e8546e078cb80d062c31ad30e50a 100644 --- a/config/locales/communication/en.yml +++ b/config/locales/communication/en.yml @@ -151,7 +151,7 @@ en: communication: blocks: alerts: - image_is_too_big: Image is too big! + file_is_too_big: File is too big! categories: basic: label: Basic blocks diff --git a/config/locales/communication/fr.yml b/config/locales/communication/fr.yml index fb1cf9db0a94cb396d7400ba0a495ab50dc53e3c..9592afc31c250fe29f67bcfd5e06064492826d5c 100644 --- a/config/locales/communication/fr.yml +++ b/config/locales/communication/fr.yml @@ -151,7 +151,7 @@ fr: communication: blocks: alerts: - image_is_too_big: L'image est trop grosse ! + file_is_too_big: Le fichier est trop lourd ! categories: basic: label: Blocs de base