function image_style_options

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.

Return value

Array of image styles both key and value are set to style name.

9 calls to image_style_options()
ConfigTestFormController::form in drupal/core/modules/config/tests/config_test/lib/Drupal/config_test/ConfigTestFormController.php
Overrides Drupal\Core\Entity\EntityFormController::form().
ImageAdminStylesTest::testNumericStyleName in drupal/core/modules/image/lib/Drupal/image/Tests/ImageAdminStylesTest.php
Test creating an image style with a numeric name and ensuring it can be applied to an image.
ImageFormatter::settingsForm in drupal/core/modules/image/lib/Drupal/image/Plugin/field/formatter/ImageFormatter.php
Returns a form to configure settings for the formatter.
ImageFormatter::settingsSummary in drupal/core/modules/image/lib/Drupal/image/Plugin/field/formatter/ImageFormatter.php
Returns a short summary for the current formatter settings.
ImageStyleDeleteForm::buildForm in drupal/core/modules/image/lib/Drupal/image/Form/ImageStyleDeleteForm.php
Implements \Drupal\Core\Form\FormInterface::buildForm().

... See full list

File

drupal/core/modules/image/image.module, line 502
Exposes global functionality for creating image styles.

Code

function image_style_options($include_empty = TRUE) {
  $styles = entity_load_multiple('image_style');
  $options = array();
  if ($include_empty && !empty($styles)) {
    $options[''] = t('- None -');
  }
  foreach ($styles as $name => $style) {
    $options[$name] = $style
      ->label();
  }
  if (empty($options)) {
    $options[''] = t('No defined styles');
  }
  return $options;
}