A platform for community discussion. Free, open, simple.
FIX: Return `naturalWidth` and `naturalHeight` for Composer image sizes (#13271)
jbrw9d8bc6a405b6
diff --git a/app/assets/javascripts/discourse/app/controllers/composer.js b/app/assets/javascripts/discourse/app/controllers/composer.jsindex e0c09b70b51..0c4be8430c4 100644--- a/app/assets/javascripts/discourse/app/controllers/composer.js+++ b/app/assets/javascripts/discourse/app/controllers/composer.js@@ -770,14 +770,15 @@ export default Controller.extend({// TODO: This should not happen in modelconst imageSizes = {};- $("#reply-control .d-editor-preview img").each((i, e) => {- const $img = $(e);- const src = $img.prop("src");+ document+ .querySelectorAll("#reply-control .d-editor-preview img")+ .forEach((e) => {+ const src = e.src;- if (src && src.length) {- imageSizes[src] = { width: $img.width(), height: $img.height() };- }- });+ if (src && src.length) {+ imageSizes[src] = { width: e.naturalWidth, height: e.naturalHeight };+ }+ });const promise = composer.save({ imageSizes, editReason: this.editReason })