<p>How about just using the <code>getHeight()</code> and <code>getWidth()</code> methods available on the <a href="http://buildwithcraft.com/docs/templating/assetfilemodel">AssetFileModel</a>? Something like this:</p>

<pre><code>{% set myImage = entry.imagesField.first %}

{% if myImage.getWidth() &lt; myImage.getHeight() %}
  {# portrait #}
{% elseif myImage.getWidth() &gt; myImage.getHeight() %}
  {# landscape #}
{% else %}
  {# square #}
{% endif %}
</code></pre>

CC BY-SA 3.0
2014-08-06T12:54:54.303Z
Seems like that’s it. Somehow i must have overlooked those. Gonna try this. Thanks!
Marcus Scheller
CC BY-SA 3.0
2014-08-06T12:57:52.870Z
No problem, happy to help :)
Josh Angell
CC BY-SA 3.0
2014-08-06T12:33:13.573Z
2014-08-06T12:33:13.573Z
Josh Angell
<p>In a current project we will list entries in a masonry-style grid view where the entry’s respective cover image should be styled differently based on their image format. Landscape vs. portrait and -- of course -- square.</p>

<p>I haven’t found anything on here or in the docs pointing to a possible way of doing this.</p>

<assets><format><image>
Is there a way to find out if images (assets) are landscape or portrait?
# Is there a way to find out if images (assets) are landscape or portrait?

(Asked by: username_0 on 2014-08-06)

In a current project we will list entries in a masonry-style grid view where the entry’s respective cover image should be styled differently based on their image format. Landscape vs. portrait and -- of course -- square.

I haven’t found anything on here or in the docs pointing to a possible way of doing this.

**Tags:** assets, format, image


---

## 1 answers

### Answer by username_1 on 2014-08-06. Score: 11 | Accepted answer

How about just using the getHeight() and getWidth() methods available on the AssetFileModel? Something like this:
{% set myImage = entry.imagesField.first %}

{% if myImage.getWidth() < myImage.getHeight() %}
  {# portrait #}
{% elseif myImage.getWidth() > myImage.getHeight() %}
  {# landscape #}
{% else %}
  {# square #}
{% endif %}

> **Comments:**
> **username_0**: Seems like that’s it. Somehow i must have overlooked those. Gonna try this. Thanks!  
> **username_1**: No problem, happy to help :)  

---

