diff --git a/themes/grav/templates/forms/fields/uploads/uploads.html.twig b/themes/grav/templates/forms/fields/uploads/uploads.html.twig index 9951a50c..8fb46cb9 100644 --- a/themes/grav/templates/forms/fields/uploads/uploads.html.twig +++ b/themes/grav/templates/forms/fields/uploads/uploads.html.twig @@ -37,13 +37,24 @@ thisDropzone = this; $.get(URI + '/task:listmedia', function(data) { $.each(data, function(filename, data){ - var mockFile = { name: filename, size: data.size, extras: data }; + var mockFile = { name: filename, size: data.size, accepted: true, extras: data }; thisDropzone.files.push(mockFile); thisDropzone.options.addedfile.call(thisDropzone, mockFile); thisDropzone.options.thumbnail.call(thisDropzone, mockFile, data.url); }); }); + this.on("complete", function(file) { + if (file.accepted) return; + var data = {status: 'error', message: 'Unsupported file type: ' + file.name.match(/\..+/).join('')}; + $.proxy(modalError, this, { + file: file, + data: data, + mode: 'removeFile', + msg: '

An error occurred while trying to add the file '+file.name+'

'+data.message+'
' + })(); + }); + this.on('success', function(file, response){ thisDropzone = this; $.proxy(modalError, this, { @@ -55,6 +66,7 @@ }); this.on('removedfile', function(file) { + if (!file.accepted) return; thisDropzone = this; $.post(URI + '/task:delmedia', {filename: file.name}, function(data){ $.proxy(modalError, thisDropzone, {