Accept portrait images for square crop

This commit is contained in:
2026-08-06 00:48:33 +02:00
parent 82d0a07e1f
commit 057726b543
3 changed files with 15 additions and 7 deletions
+7 -3
View File
@@ -992,11 +992,15 @@ function renderPictureCandidates(items) {
return;
}
const isTooSmall = image.naturalWidth < MIN_PRODUCT_PICTURE_SIZE || image.naturalHeight < MIN_PRODUCT_PICTURE_SIZE;
const shortestSide = Math.min(image.naturalWidth, image.naturalHeight);
const longestSide = Math.max(image.naturalWidth, image.naturalHeight);
const isTooSmall = longestSide < MIN_PRODUCT_PICTURE_SIZE;
row.classList.toggle("is-too-small", isTooSmall);
dimensions.textContent = isTooSmall
? `Size: ${image.naturalWidth} x ${image.naturalHeight}px - too small, min ${MIN_PRODUCT_PICTURE_SIZE} x ${MIN_PRODUCT_PICTURE_SIZE}`
: `Size: ${image.naturalWidth} x ${image.naturalHeight}px`;
? `Size: ${image.naturalWidth} x ${image.naturalHeight}px - too small, min long side ${MIN_PRODUCT_PICTURE_SIZE}px`
: shortestSide < MIN_PRODUCT_PICTURE_SIZE
? `Size: ${image.naturalWidth} x ${image.naturalHeight}px - OK for 1:1 crop`
: `Size: ${image.naturalWidth} x ${image.naturalHeight}px`;
});
image.addEventListener("error", () => {
dimensions.textContent = "Size: image preview failed";