function image_style_options
7.x 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.
6 calls to image_style_options()
- ImageAdminStylesUnitTest::testNumericStyleName in drupal-7.x/
modules/ image/ image.test - Test creating an image style with a numeric name and ensuring it can be applied to an image.
- image_field_formatter_settings_form in drupal-7.x/
modules/ image/ image.field.inc - Implements hook_field_formatter_settings_form().
- image_field_formatter_settings_summary in drupal-7.x/
modules/ image/ image.field.inc - Implements hook_field_formatter_settings_summary().
- image_field_widget_settings_form in drupal-7.x/
modules/ image/ image.field.inc - Implements hook_field_widget_settings_form().
- image_style_delete_form in drupal-7.x/
modules/ image/ image.admin.inc - Form builder; Form for deleting an image style.
File
- drupal-7.x/
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;
}