[Drupal] How to get all image styles in Drupal?
In one of my recent project I had a task to create a content type with a select list field of all image styles. But how can we get all image styles in Drupal? In Drupal there is an option to create different image styles using a module 'image'. Image module allows users to upload images into Drupal with proper permissions along with this its thumbnails and additional sizes are created automatically. Image module also gives an image_styles() function that can be used to get all image styles and their settings.
This function returns an array of styles keyed by the image style ID (isid). For example :
Array ( [thumbnail] => Array ( [label] => Thumbnail (100x100) [effects] => Array (  => Array ( [label] => Scale [help] => Scaling will maintain the aspect-ratio of the original image. If only a single dimension is specified, the other dimension will be calculated. [effect callback] => image_scale_effect [dimensions callback] => image_scale_dimensions [form callback] => image_scale_form [summary theme] => image_scale_summary [module] => image [name] => image_scale [data] => Array ( [width] => 100 [height] => 100 [upscale] => 1 ) [weight] => 0 ) ) [name] => thumbnail [module] => image [storage] => 4 ) )
This function exposes global functionality for creating image styles. Here no need of any parameter to be passed. Hope this article helps.
If you face any doubts understanding the above, please feel free to get in touch with us.