diff --git a/_layouts/gallery-photo.html b/_layouts/gallery-photo.html
index ed99ac1..13b4df4 100644
--- a/_layouts/gallery-photo.html
+++ b/_layouts/gallery-photo.html
@@ -33,8 +33,16 @@
+ {% assign maxsize = 0 %}
+ {% assign maxref = false %}
+ {% for size in page.sizes %}
+ {% if maxsize < size[1].height * size[1].width %}
+ {% assign maxsize = size[1].height * size[1].width %}
+ {% assign maxref = size %}
+ {% endif %}
+ {% endfor %}
-
+
{% if content %}