diff --git a/src/pages/[...id].tsx b/src/pages/[...id].tsx index 07edb00..6bd44df 100644 --- a/src/pages/[...id].tsx +++ b/src/pages/[...id].tsx @@ -9,12 +9,18 @@ export default function EmbeddedImage({ image, title, username, color, normal, e const dataURL = (route: string) => `${route}/${image.file}`; const updateImage = () => { + const imageEl = document.getElementById('image_content') as HTMLImageElement; + const original = new Image; original.src = dataURL('/raw'); - const imageEl = document.getElementById('image_content') as HTMLImageElement; - imageEl.width = Math.floor(original.width * Math.min((innerHeight / original.height), (innerWidth / original.width))); - imageEl.height = innerHeight; + if (original.width > innerWidth) { + imageEl.width = Math.floor(original.width * Math.min((innerHeight / original.height), (innerWidth / original.width))); + imageEl.height = innerHeight; + } else { + imageEl.width = original.width; + imageEl.height = original.height; + } }; if (typeof window !== 'undefined') window.onresize = () => updateImage(); @@ -36,10 +42,10 @@ export default function EmbeddedImage({ image, title, username, color, normal, e )} - - > )} + +