function image_style_options

image_style_options($include_empty = TRUE, $output = CHECK_PLAIN)

Gets an array of image styles suitable for using as select list options.

Parameters

$include_empty: If TRUE a <none> option will be inserted in the options array.

$output: Optional flag determining how the options will be sanitized on output. Leave this at the default (CHECK_PLAIN) if you are using the output of this function directly in an HTML context, such as for checkbox or radio button labels, and do not plan to sanitize it on your own. If using the output of this function as select list options (its primary use case), you should instead set this flag to PASS_THROUGH to avoid double-escaping of the output (the form API sanitizes select list options by default).

Return value

Array of image styles with the machine name as key and the label as value.

File

modules/image/image.module, line 781
Exposes global functionality for creating image styles.

Code

function image_style_options($include_empty = TRUE, $output = CHECK_PLAIN) {
  $styles = image_styles();
  $options = array();
  if ($include_empty && !empty($styles)) {
    $options[''] = t('<none>');
  }
  foreach ($styles as $name => $style) {
    $options[$name] = ($output == PASS_THROUGH) ? $style['label'] : check_plain($style['label']);
  }

  if (empty($options)) {
    $options[''] = t('No defined styles');
  }
  return $options;
}

© 2001–2016 by the original authors
Licensed under the GNU General Public License, version 2 and later.
Drupal is a registered trademark of Dries Buytaert.
https://api.drupal.org/api/drupal/modules!image!image.module/function/image_style_options/7.x