<p>You can pass an array instead of the image-transform handle to the <code>getUrl()</code> function </p>

<pre><code>{% set transform = {
    'width' =&gt; 600,
    'height' =&gt; (asset.getWidth() &lt;= 800)? asset.getWidth() : 800
} %}
{{ asset.getUrl(transform) }}
</code></pre>

CC BY-SA 4.0
2018-05-11T11:06:51.327Z
2018-05-11T11:06:51.327Z
Robin Schambach
<p>Is it possible to define an aspect ratio / set a max height on an image transform, without using a plugin?</p>

<p>Let's say the width is fixed to 600px, but the height can be any value up to 800px?</p>

<image-transforms>
Set max-height on image transforms?
# Set max-height on image transforms?

(Asked by: username_0 on 2018-05-11)

Is it possible to define an aspect ratio / set a max height on an image transform, without using a plugin?

Let's say the width is fixed to 600px, but the height can be any value up to 800px?

**Tags:** image-transforms


---

## 1 answers

### Answer by username_1 on 2018-05-11. Score: 4 | Accepted answer

You can pass an array instead of the image-transform handle to the getUrl() function 
{% set transform = {
    'width' => 600,
    'height' => (asset.getWidth() <= 800)? asset.getWidth() : 800
} %}
{{ asset.getUrl(transform) }}


---

