Get all available asset transforms Is there a way to get all available image transforms in a template?
I would like to generate the srcset for responsive images programmatically.

I thought of creating a macro for that but haven't found any information about how to loop over all the registered image transforms.
Craft 3 PHP

$transforms = Craft::$app-&gt;getAssetTransforms()-&gt;getAllTransforms();
foreach($allTransforms as $transform){
    echo $asset-&gt;getUrl($transform-&gt;handle);
}


Craft 3 Twig

{% set allTransforms = craft.app.getAssetTransforms.getAllTransforms() %}
{% for transform in allTransforms %}            
    {{ asset.getUrl(transform.handle) }}
{% endfor %}


Craft 2 PHP

$allTansforms = craft()-&gt;assetTransforms-&gt;getAllTransforms();


Craft 2 Twig

You'll need a plugin for this because you don't have access to that component

{% set allTransforms = craft.pluginHandle.getAllAssetTransforms %}


And in your PluginVariable

public function getAllAssetTransforms(){
    return craft()-&gt;assetTransforms-&gt;getAllTransforms();
}