From d518b302a0ef972b909c00e0073ab1c2942f0360 Mon Sep 17 00:00:00 2001 From: Rafael dos Santos Silva Date: Thu, 4 Feb 2021 00:41:07 -0300 Subject: [PATCH] FIX: Composer upload icon regression because of WEBP (#11959) Similar to https://github.com/discourse/discourse/commit/ba9fbb3443d6f258b928676cb8fd794bcf86284b Reported on https://meta.discourse.org/t/image-icon-has-changed-to-upload-icon/178247?u=falco --- .../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 1e424f9aedf..92672343a7a 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|heic|heif)$/)) { + if (imageUrl.match(/\.(jpg|jpeg|png|gif|heic|heif|webp)$/)) { 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 6be776006ff..947035431e1 100644 --- a/app/assets/javascripts/discourse/app/lib/uploads.js +++ b/app/assets/javascripts/discourse/app/lib/uploads.js @@ -118,7 +118,7 @@ function validateUploadedFile(file, opts) { return true; } -const IMAGES_EXTENSIONS_REGEX = /(png|jpe?g|gif|svg|ico|heic|heif)/i; +const IMAGES_EXTENSIONS_REGEX = /(png|jpe?g|gif|svg|ico|heic|heif|webp)/i; function extensionsToArray(exts) { return exts @@ -182,7 +182,7 @@ export function authorizedExtensions(staff, siteSettings) { function authorizedImagesExtensions(staff, siteSettings) { return authorizesAllExtensions(staff, siteSettings) - ? "png, jpg, jpeg, gif, svg, ico, heic, heif" + ? "png, jpg, jpeg, gif, svg, ico, heic, heif, webp" : imagesExtensions(staff, siteSettings).join(", "); }