diff --git a/layouts/partials/GetImageRatio b/layouts/partials/GetImageRatio
index 29425d1a8721777ec8c7daa5b706913fe7c6e733..b17f0b3dd54aa045ee1d273ded25538d8574d6ff 100644
--- a/layouts/partials/GetImageRatio
+++ b/layouts/partials/GetImageRatio
@@ -2,7 +2,9 @@
 {{ $ratio := 1 }}
 
 {{ if $image }}
-  {{ $ratio = div (float $image.width) (float $image.height) }}
+  {{ if and $image.width $image.height }}
+    {{ $ratio = div (float $image.width) (float $image.height) }}
+  {{ end }}
 {{ end }}
 
 {{ return $ratio }}
\ No newline at end of file