diff --git a/src/app/molecules/image-pack/ImagePackUpload.jsx b/src/app/molecules/image-pack/ImagePackUpload.jsx index 9358856..0b7c23b 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 57891a9..83fd20f 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));