Answers.Body: <p>Sortof – you can find out what an image’s width would be with a transform applied to it via AssetFileModel’s - <a href="http://buildwithcraft.com/docs/templating/assetfilemodel#getWidth">getWidth()</a> and <a href="http://buildwithcraft.com/docs/templating/assetfilemodel#getHeight">getHeigth()</a></p>
  
  <pre><code>&lt;img src="
      {%- if image.getWidth(transform) &gt; 970 -%}
          {{ image.getUrl(transform) }}
      {%- else -%}
          {{ image.url }}
      {%- endif %}" alt="{{ image.title }}" /&gt;
  </code></pre>
  
  <p>And for extra cleanliness points, you can update the code to use <a href="http://buildwithcraft.com/docs/templating/assetfilemodel#setTransform">setTransform()</a> instead of jumbling all that code into your <code>&lt;img&gt;</code> tag:</p>
  
  <pre><code>{% if image.getWidth(transform) &gt; 970 %}
      {% do image.setTransform(transform) %}
  {% endif %}
  
  &lt;img src="{{ image.url }}" alt="{{ image.title }}" /&gt;
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-06-12T00:26:34.343Z
Answers.Text: Thanks Brandon! I award you a correct answer, 12 gold coins, and a stack Exchange invisibility cloak. Once you reach 7 merit badges you will be elegible for meta.meta.meta.craftcms.stackexchange.com. (currently in private beta).
Answers.UserDisplayName: James Muspratt
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-06-12T00:40:01.657Z
Answers.Text: That's so meta.
Answers.UserDisplayName: Jeremy Gimbel
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-06-12T00:18:00.650Z
Answers.LastActivityDate: 2014-06-12T00:18:00.650Z
Answers.UserDisplayName: Brandon Kelly
Body: <p>Can I extract a transform's settings from its handle? I'm trying to avoid upscaling images using the workaround, and I'd like to set my transform handle dynamically within some conditionals. (see <a href="https://plus.google.com/115463622553757255119/posts/M4AWTz9PKPi">this link</a>).</p>
  
  <p>Say I'm looping through a matrix field as in the example below, using a dropdown variable to determine which transform is best. When outputting the image I'd like to replace that '970' with pixel width specific to that the asset transform. I'm sure this is wrong, but I'm imagining something like <code>getTransform(transform).width.</code></p>
  
  <pre><code>{% if block.formation == 'twins' %} 
      {% set transform = 'medium' %}
  {% else%}
      {% set transform = 'large' %}
  {% endif %}
  
  &lt;figure&gt;
    &lt;img src="{% if image.getWidth() &gt; 970 %}{{ image.getUrl(transform) }}{% else %}{{ image.url }}{% endif %}" alt="{{ image.title }}" /&gt;
  &lt;/figure&gt;
  </code></pre>
  
Tags: <image-transforms>
Title: Transform Info from Handle?
ThreadText: # Transform Info from Handle?
  
  (Asked by: username_0 on 2014-06-12)
  
  Can I extract a transform's settings from its handle? I'm trying to avoid upscaling images using the workaround, and I'd like to set my transform handle dynamically within some conditionals. (see [this link](https://plus.google.com/115463622553757255119/posts/M4AWTz9PKPi)).
  
  Say I'm looping through a matrix field as in the example below, using a dropdown variable to determine which transform is best. When outputting the image I'd like to replace that '970' with pixel width specific to that the asset transform. I'm sure this is wrong, but I'm imagining something like `getTransform(transform).width.`
  
  ```
  {% if block.formation == 'twins' %} 
      {% set transform = 'medium' %}
  {% else%}
      {% set transform = 'large' %}
  {% endif %}
  
  <figure>
    <img src="{% if image.getWidth() > 970 %}{{ image.getUrl(transform) }}{% else %}{{ image.url }}{% endif %}" alt="{{ image.title }}" />
  </figure>
  
  ```
  
  **Tags:** image-transforms
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2014-06-12. Score: 20 | Accepted answer
  
  Sortof – you can find out what an image’s width would be with a transform applied to it via AssetFileModel’s - [getWidth()](http://buildwithcraft.com/docs/templating/assetfilemodel#getWidth) and [getHeigth()](http://buildwithcraft.com/docs/templating/assetfilemodel#getHeight)
  
  ```
  <img src="
      {%- if image.getWidth(transform) > 970 -%}
          {{ image.getUrl(transform) }}
      {%- else -%}
          {{ image.url }}
      {%- endif %}" alt="{{ image.title }}" />
  
  ```
  
  And for extra cleanliness points, you can update the code to use [setTransform()](http://buildwithcraft.com/docs/templating/assetfilemodel#setTransform) instead of jumbling all that code into your `<img>` tag:
  
  ```
  {% if image.getWidth(transform) > 970 %}
      {% do image.setTransform(transform) %}
  {% endif %}
  
  <img src="{{ image.url }}" alt="{{ image.title }}" />
  
  ```
  
  > **Comments:**
  > **username_0**: Thanks username_1! I award you a correct answer, 12 gold coins, and a stack Exchange invisibility cloak. Once you reach 7 merit badges you will be elegible for meta.meta.meta.craftcms.stackexchange.com. (currently in private beta).  
  > **username_2**: That's so meta.  
  
  ---
  
  