Skip to content

Commit

Permalink
Merge pull request #2858 from ecency/nt/img-ratio-fix
Browse files Browse the repository at this point in the history
Nt/img ratio fix
  • Loading branch information
feruzm committed Apr 16, 2024
2 parents 50ee58e + a757bfb commit a9fcac0
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/components/autoHeightImage/autoHeightImage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,11 @@ export const AutoHeightImage = ({
const _initialHeight = useMemo(() => {
let _height = contentWidth / (16 / 9);
if (metadata && metadata.image && metadata.image_ratios) {

metadata.image_ratios.forEach((_ratio, index) => {
const url = metadata.image[index];

if (url && !Number.isNaN(_ratio)) {
if (url && Number.isFinite(_ratio) && _ratio !== 0) {
const poxifiedUrl = proxifyImageSrc(
url,
undefined,
Expand All @@ -40,7 +41,6 @@ export const AutoHeightImage = ({
);

if (imgUrl === poxifiedUrl) {
const _ratio = metadata.image_ratios[index];
_height = contentWidth / _ratio;
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/utils/editor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ export const extractMetadata = async ({
(width, height) => {
resolve(width / height);
},
() => resolve(0),
() => resolve(NaN),
);
});
})
Expand Down

0 comments on commit a9fcac0

Please sign in to comment.