How to check if an Image Transform exists? Is there an elegant way to check if an image transform exists?

{% if craft.imageTransformExists('thumb') %}
  &lt;img src="{{asset.getUrl(thumb)}}" alt="Image"&gt;
{% else %}
  This image transform doesn't exists, please create it
{% endif %}
Like Brad says, you'd need to write a custom plugin – specifically, one that provides a Template Variable class exposing the AssetTransformsService's getTransformByHandle method.

The variable class could look something like this:

class MyPluginVariable
{

    public function imageTransformExists($handle)
    {
        // Returns null if transform doesn't exist
        return craft()-&gt;assetTransforms-&gt;getTransformByHandle($handle);
    }

}


Then, you'd be able to test for named image transforms in your templates like this:

{% if craft.myPlugin.imageTransformExists('thumb') %}
    ...
{% endif %}


If you're not familiar with plugin development, it might be useful to use the Business Logic plugin as a starting point – it even has a Variable class which you could just drop the above imageTransformExists method into.