Answers.Body: <p>Your variable assignment is wrong. <code>{% set customRatio == 1/1 %}</code> should be <code>{% set customRatio = 1/1 %}</code>. </p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-11-18T10:50:14.517Z
Answers.Text: yeah, okay. I'm an idiot 
Answers.UserDisplayName: KSPR
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-11-17T12:41:42.460Z
Answers.LastActivityDate: 2019-11-17T12:41:42.460Z
Answers.UserDisplayName: André Elvan
Body: <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>
  
Tags: <templating><variable><plugin-imager>
Title: Pass aspect ratio as variable into imager
ThreadText: # 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 })
   %}
   <img src="{{ transformedImage.url }}">
  
  ```
  
  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 })
   %}
   <img src="{{ transformedImage.url }}">
  
  ```
  
  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   
  
  ---
  
  