<p>Your variable assignment is wrong. <code>{% set customRatio == 1/1 %}</code> should be <code>{% set customRatio = 1/1 %}</code>. </p>

CC BY-SA 4.0
2019-11-18T10:50:14.517Z
yeah, okay. I'm an idiot 
KSPR
CC BY-SA 4.0
2019-11-17T12:41:42.460Z
2019-11-17T12:41:42.460Z
André Elvan
<p>I use imager to transform images and I want to pass the image ratio as a variable:</p>

<pre><code>{% set customRatio = 1/1 %}

{% set image = craft.assets().one() %}
{% set transformedImage = craft.imager.transformImage(image,
    { width: 1000, ratio: customRatio })
 %}
 &lt;img src="{{ transformedImage.url }}"&gt;
</code></pre>

<p>This does not work. There is something wrong with how it is passed along. If I pass it as a string: <code>{% set customRatio = '1/1' %}</code>. It doesn't work either. (No errors in both cases).</p>

<p>But when I write it directely into the imager markup like this:</p>

<pre><code>{% set image = craft.assets().one() %}
{% set transformedImage = craft.imager.transformImage(image,
    { width: 1000, ratio: 1/1 })
 %}
 &lt;img src="{{ transformedImage.url }}"&gt;
</code></pre>

<p>Then it works. But why?</p>

<templating><variable><plugin-imager>
Pass aspect ratio as variable into imager
# Pass aspect ratio as variable into imager

(Asked by: username_0 on 2019-11-17)

I use imager to transform images and I want to pass the image ratio as a variable:
{% set customRatio = 1/1 %}

{% set image = craft.assets().one() %}
{% set transformedImage = craft.imager.transformImage(image,
    { width: 1000, ratio: customRatio })
 %}
 

This does not work. There is something wrong with how it is passed along. If I pass it as a string: {% set customRatio = '1/1' %}. It doesn't work either. (No errors in both cases).
But when I write it directely into the imager markup like this:
{% set image = craft.assets().one() %}
{% set transformedImage = craft.imager.transformImage(image,
    { width: 1000, ratio: 1/1 })
 %}
 

Then it works. But why?

**Tags:** templating, variable, plugin-imager

---

## 1 answers

### Answer by username_1 on 2019-11-17. Score: 2 | Accepted answer

Your variable assignment is wrong. `{% set customRatio == 1/1 %}` should be `{% set customRatio = 1/1 %}`.

> **Comments:**
> **username_0**: yeah, okay. I'm an idiot   

---

