<p>In Craft 3 you can call it like this: </p>

<pre><code>{% set transformDimensions = craft.app.assetTransforms.getTransformByHandle('contentWidth') %}
</code></pre>

<p>width: <code>{{ transformDimensions.width }}</code><br>
height: <code>{{ transformDimensions.height }}</code><br>
etc.</p>

CC BY-SA 4.0
2019-11-07T14:45:33.643Z
2019-11-07T14:45:33.643Z
outline4
<p>Craft does not provide the assetTransformService in the craft.variable but you can include it by yourself.
Create a function in your PluginVariable.php that does<br></p>

<pre><code>public function getTransformationByHandle($handle){
    return craft()-&gt;assetTransforms-&gt;getTransformByHandle($handle);
}
</code></pre>

<p>and in your twig template<br>
<code>{% set transformation = craft.pluginHandle.getTransformationByHandle('yourHandle') %}</code></p>

<p>Edit: if you don't have a custom plugin then visit this page <a href="https://pluginfactory.io/" rel="nofollow noreferrer">Pluginfactory</a> fill out the inputs and select the lightswitch for "variable" paste my function into the <code>/variables/pluginHandleVariable.php</code> file and create a folder with the same name as your pluginhandle (the one you inserted in the input at the page) in <code>/app/plugins/</code> then go to the control panel, install the plugin.</p>

CC BY-SA 3.0
2018-02-28T16:05:25.783Z
Sorry for the (very) late reply but this just solved my problem! Thank you very much!
mdmngz
CC BY-SA 3.0
2017-10-21T12:59:37.707Z
2017-10-21T13:11:59.707Z
2017-10-21T13:11:59.707Z
Robin Schambach
<p>Is it possible to retrieve a control panel defined imagetransform’s dimensions in a front-end template without having to retrieve an asset? Because when there is no asset provided, I can't seem to find a (dynamic) way to get the width and height of the transform in order to calculate dimensions for a placeholder div</p>

<image-transforms>
Get a defined image-transform's width and height in front-end template
# Get a defined image-transform's width and height in front-end template

(Asked by: username_0 on 2017-10-21)

Is it possible to retrieve a control panel defined imagetransform’s dimensions in a front-end template without having to retrieve an asset? Because when there is no asset provided, I can't seem to find a (dynamic) way to get the width and height of the transform in order to calculate dimensions for a placeholder div

**Tags:** image-transforms


---

## 2 answers

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

In Craft 3 you can call it like this: 
{% set transformDimensions = craft.app.assetTransforms.getTransformByHandle('contentWidth') %}

width: {{ transformDimensions.width }}
height: {{ transformDimensions.height }}
etc.


---

### Answer by username_2 on 2017-10-21. Score: 1

Craft does not provide the assetTransformService in the craft.variable but you can include it by yourself.
Create a function in your PluginVariable.php that does
public function getTransformationByHandle($handle){
    return craft()->assetTransforms->getTransformByHandle($handle);
}

and in your twig template
{% set transformation = craft.pluginHandle.getTransformationByHandle('yourHandle') %}
Edit: if you don't have a custom plugin then visit this page Pluginfactory fill out the inputs and select the lightswitch for "variable" paste my function into the /variables/pluginHandleVariable.php file and create a folder with the same name as your pluginhandle (the one you inserted in the input at the page) in /app/plugins/ then go to the control panel, install the plugin.

> **Comments:**
> **username_0**: Sorry for the (very) late reply but this just solved my problem! Thank you very much!  

---

