From ce1e263d5730e768929bc75e6376df2e42daccca Mon Sep 17 00:00:00 2001 From: Ajay Bura <32841439+ajbura@users.noreply.github.com> Date: Thu, 11 Aug 2022 13:33:54 +0530 Subject: [PATCH] Only scale image bigger than 512px (#731) --- src/app/molecules/image-pack/ImagePackUpload.jsx | 2 ++ src/util/common.js | 3 +++ 2 files changed, 5 insertions(+) diff --git a/src/app/molecules/image-pack/ImagePackUpload.jsx b/src/app/molecules/image-pack/ImagePackUpload.jsx index 9358856d..0b7c23b7 100644 --- a/src/app/molecules/image-pack/ImagePackUpload.jsx +++ b/src/app/molecules/image-pack/ImagePackUpload.jsx @@ -41,11 +41,13 @@ function ImagePackUpload({ onUpload }) { const img = evt.target.files[0]; if (!img) return; setImgFile(img); + shortcodeRef.current.value = img.name.slice(0, img.name.indexOf('.')); shortcodeRef.current.focus(); }; const handleRemove = () => { setImgFile(null); inputRef.current.value = null; + shortcodeRef.current.value = ''; }; return ( diff --git a/src/util/common.js b/src/util/common.js index 57891a9d..83fd20fe 100644 --- a/src/util/common.js +++ b/src/util/common.js @@ -166,6 +166,9 @@ export function scaleDownImage(imageFile, width, height) { img.onload = () => { let newWidth = img.width; let newHeight = img.height; + if (newHeight <= height && newWidth <= width) { + resolve(imageFile); + } if (newHeight > height) { newWidth = Math.floor(newWidth * (height / newHeight));