function image_style_options

cis7 image.module image_style_options($include_empty = TRUE, $output = CHECK_PLAIN)
cle7 image.module image_style_options($include_empty = TRUE, $output = CHECK_PLAIN)
elmsmedia7 image.module image_style_options($include_empty = TRUE, $output = CHECK_PLAIN)
icor7 image.module image_style_options($include_empty = TRUE, $output = CHECK_PLAIN)
meedjum_blog7 image.module image_style_options($include_empty = TRUE, $output = CHECK_PLAIN)
mooc7 image.module 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.

14 calls to image_style_options()

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;
}