From ba9fbb3443d6f258b928676cb8fd794bcf86284b Mon Sep 17 00:00:00 2001 From: Blake Erickson Date: Mon, 17 Aug 2020 19:34:37 -0600 Subject: [PATCH] FIX: Composer upload icon regression because of HEIC Now that HEIC conversion is enabled by default we need to update a few file extension checks to include `heic` and heif` formats. https://meta.discourse.org/t/-/144326/23?u=blake bug reported here: https://meta.discourse.org/t/-/161197?u=blake --- .../javascripts/discourse/app/controllers/upload-selector.js | 2 +- app/assets/javascripts/discourse/app/lib/uploads.js | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/app/assets/javascripts/discourse/app/controllers/upload-selector.js b/app/assets/javascripts/discourse/app/controllers/upload-selector.js index 32e834aaa7e..5088922871c 100644 --- a/app/assets/javascripts/discourse/app/controllers/upload-selector.js +++ b/app/assets/javascripts/discourse/app/controllers/upload-selector.js @@ -56,7 +56,7 @@ export default Controller.extend(ModalFunctionality, { const imageUrl = this.imageUrl || ""; const toolbarEvent = this.toolbarEvent; - if (imageUrl.match(/\.(jpg|jpeg|png|gif)$/)) { + if (imageUrl.match(/\.(jpg|jpeg|png|gif|heic|heif)$/)) { toolbarEvent.addText(`![](${imageUrl})`); } else { toolbarEvent.addText(imageUrl); diff --git a/app/assets/javascripts/discourse/app/lib/uploads.js b/app/assets/javascripts/discourse/app/lib/uploads.js index 83bc9ec5581..d71784b712b 100644 --- a/app/assets/javascripts/discourse/app/lib/uploads.js +++ b/app/assets/javascripts/discourse/app/lib/uploads.js @@ -113,7 +113,7 @@ function validateUploadedFile(file, opts) { return true; } -const IMAGES_EXTENSIONS_REGEX = /(png|jpe?g|gif|svg|ico)/i; +const IMAGES_EXTENSIONS_REGEX = /(png|jpe?g|gif|svg|ico|heic|heif)/i; function extensionsToArray(exts) { return exts @@ -177,7 +177,7 @@ export function authorizedExtensions(staff, siteSettings) { function authorizedImagesExtensions(staff, siteSettings) { return authorizesAllExtensions(staff, siteSettings) - ? "png, jpg, jpeg, gif, svg, ico" + ? "png, jpg, jpeg, gif, svg, ico, heic, heif" : imagesExtensions(staff, siteSettings).join(", "); }