Skip to content

Commit

Permalink
limit max upload file size
Browse files Browse the repository at this point in the history
  • Loading branch information
yksflip committed Jul 12, 2023
1 parent 2991fbb commit fb8eb8c
Show file tree
Hide file tree
Showing 8 changed files with 20 additions and 0 deletions.
1 change: 1 addition & 0 deletions app/javascript/application.js
@@ -1,3 +1,4 @@
// Configure your import map in config/importmap.rb. Read more: https://github.com/rails/importmap-rails
import "trix"
import "@rails/actiontext"
import "./trix-editor-overrides"
7 changes: 7 additions & 0 deletions app/javascript/trix-editor-overrides.js
@@ -0,0 +1,7 @@
// app/javascript/trix-editor-overrides.js
window.addEventListener("trix-file-accept", function(event) {
if (event.file.size > 1024 * 1024 * 512) {
event.preventDefault()
alert(I18n.t('js.trix_editor.file_size_alert'))
}
})
2 changes: 2 additions & 0 deletions config/locales/de.yml
Expand Up @@ -1216,6 +1216,8 @@ de:
js:
ordering:
confirm_change: Änderungen an dieser Bestellung gehen verloren, wenn zu einer anderen Bestellung gewechselt wird. Möchtest Du trotzdem wechseln?
trix_editor:
file_size_alert: Der Dateianhang ist zu groß! Die maximale Größe beträgt 512Mb
layouts:
email:
footer_1_separator: "--"
Expand Down
2 changes: 2 additions & 0 deletions config/locales/en.yml
Expand Up @@ -1219,6 +1219,8 @@ en:
js:
ordering:
confirm_change: Modifications to this order will be lost when you change the order. Do you want to lose the changes you made and continue?
trix_editor:
file_size_alert: The file is to large! The supported file size is 512Mb!
layouts:
email:
footer_1_separator: "--"
Expand Down
2 changes: 2 additions & 0 deletions config/locales/es.yml
Expand Up @@ -1080,6 +1080,8 @@ es:
js:
ordering:
confirm_change: Las modificaciones sobre este pedido se perderán cuando cambies el pedido. ¿Quieres perder los cambios que has hecho y continuar?
trix_editor:
file_size_alert: ¡El archivo adjunto es demasiado grande! El tamaño máximo es de 512Mb
layouts:
email:
footer_4_help: 'Ayuda: %{url}'
Expand Down
2 changes: 2 additions & 0 deletions config/locales/fr.yml
Expand Up @@ -831,6 +831,8 @@ fr:
js:
ordering:
confirm_change: Les changements apportés à cette commande vont être perdus. Est-ce que tu veux vraiment continuer?
trix_editor:
file_size_alert: Le fichier joint est trop volumineux ! La taille maximale est de 512Mb
layouts:
email:
footer_3_homepage: 'Boufcoop: %{url}'
Expand Down
2 changes: 2 additions & 0 deletions config/locales/nl.yml
Expand Up @@ -1189,6 +1189,8 @@ nl:
js:
ordering:
confirm_change: Als je naar een andere bestelling gaat, gaan je aanpassingen in deze bestelling verloren. Wijzigingen vergeten en naar de andere bestelling gaan?
trix_editor:
file_size_alert: De bestandsbijlage is te groot! De maximale grootte is 512Mb!
layouts:
email:
footer_1_separator: "--"
Expand Down
2 changes: 2 additions & 0 deletions config/locales/tr.yml
Expand Up @@ -1218,6 +1218,8 @@ tr:
js:
ordering:
confirm_change: Bu siparişe yapılan değişiklikler kaybolacak. Değişikliklerinizi kaybetmek ve devam etmek istiyor musunuz?
trix_editor:
file_size_alert: Dosya eki çok büyük! Maksimum boyut 512Mb
layouts:
email:
footer_1_separator: "--"
Expand Down

0 comments on commit fb8eb8c

Please sign in to comment.