diff --git a/config/app_local.example.php b/config/app_local.example.php index 4cd85f4a5..67a3eb9df 100644 --- a/config/app_local.example.php +++ b/config/app_local.example.php @@ -666,29 +666,13 @@ /** * Upload configurations. + * + * 'files' and 'media' accept all mimes, so no configuration needed. */ // 'uploadAccepted' => [ // 'audio' => [ // 'audio/*', // ], - // 'files' => [ - // 'application/msword', // .doc, .dot - // 'application/pdf', // .pdf - // 'application/vnd.openxmlformats-officedocument.wordprocessingml.document', // .docx - // 'application/vnd.ms-excel', // .xls, .xlt, .xla - // 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet', // .xlsx - // 'application/vnd.ms-powerpoint', // .ppt, .pot, .pps, .ppa - // 'application/vnd.openxmlformats-officedocument.presentationml.presentation', // .pptx - // 'application/x-mpegURL', - // 'audio/*', - // 'text/csv', - // 'text/html', - // 'text/plain', - // 'text/rtf', - // 'text/xml', - // 'image/*', - // 'video/*', - // ], // 'images' => [ // 'image/*', // ], @@ -696,24 +680,6 @@ // 'application/x-mpegURL', // 'video/*', // ], - // 'media' => [ - // 'application/msword', // .doc, .dot - // 'application/pdf', // .pdf - // 'application/vnd.openxmlformats-officedocument.wordprocessingml.document', // .docx - // 'application/vnd.ms-excel', // .xls, .xlt, .xla - // 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet', // .xlsx - // 'application/vnd.ms-powerpoint', // .ppt, .pot, .pps, .ppa - // 'application/vnd.openxmlformats-officedocument.presentationml.presentation', // .pptx - // 'application/x-mpegURL', - // 'audio/*', - // 'image/*', - // 'text/csv', - // 'text/html', - // 'text/plain', - // 'text/rtf', - // 'text/xml', - // 'video/*', - // ], // ], // 'uploadForbidden' => [ // 'mimetypes' => [ diff --git a/resources/js/app/helpers/view.js b/resources/js/app/helpers/view.js index c07e419c1..5258806e6 100644 --- a/resources/js/app/helpers/view.js +++ b/resources/js/app/helpers/view.js @@ -167,7 +167,7 @@ export default { }, acceptMimeTypes(type) { - if (!BEDITA.uploadConfig?.accepted?.[type]) { + if (['files', 'media'].includes(type) || !BEDITA.uploadConfig?.accepted?.[type]) { return ''; } @@ -198,8 +198,9 @@ export default { /** accepted mime types check */ const mimes = BEDITA.uploadConfig?.accepted; - if (mimes?.[objectType] && !this.checkAcceptedMime(mimes[objectType], fileType)) { - const msg = t`File type not accepted` + `: "${fileType}". ` + t`Accepted types` + `: "${mimes[objectType].join('", "')}".`; + const ot = objectType === 'media' ? this.getObjectTypeFromMime(fileType) : objectType; + if (ot !== 'files' && mimes?.[ot] && !this.checkAcceptedMime(mimes[ot], fileType)) { + const msg = t`File type not accepted` + `: "${fileType}". ` + t`Accepted types` + `: "${mimes[ot].join('", "')}".`; BEDITA.warning(msg); return false; diff --git a/src/View/Helper/SystemHelper.php b/src/View/Helper/SystemHelper.php index c25e0d4b2..3ab26f1bb 100644 --- a/src/View/Helper/SystemHelper.php +++ b/src/View/Helper/SystemHelper.php @@ -52,12 +52,6 @@ class SystemHelper extends Helper 'application/x-mpegURL', 'video/*', ], - 'media' => [ - 'application/x-mpegURL', - 'audio/*', - 'image/*', - 'video/*', - ], ]; /** diff --git a/templates/Element/Form/dropupload.twig b/templates/Element/Form/dropupload.twig index 6743f1650..6753bd267 100644 --- a/templates/Element/Form/dropupload.twig +++ b/templates/Element/Form/dropupload.twig @@ -1,5 +1,7 @@ {# :accepted-drop="[`.from-relation-${relationName}`,isRelationWithMedia && 'from-files']"> #} +{% set ot = objectTypes|length == 1 ? objectTypes[0] : 'media' %}
{% if uploadableNum %} - {{ element(Element.dropupload(relationsSchema[relationName]['right'])) }} + {{ element(Element.dropupload(relationsSchema[relationName]['right']), { + 'objectTypes': relationsSchema[relationName]['right'] + }) }} {% endif %}