Accept portrait images for square crop
This commit is contained in:
+7
-3
@@ -912,11 +912,15 @@ function renderPictureCandidates(items) {
|
||||
row.classList.remove("is-too-small");
|
||||
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";
|
||||
|
||||
Reference in New Issue
Block a user