function image_style_options

Same name in other branches
  1. 7.x modules/image/image.module \image_style_options()
  2. 8.9.x core/modules/image/image.module \image_style_options()
  3. 10 core/modules/image/image.module \image_style_options()
  4. 11.x core/modules/image/image.module \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

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

11 calls to image_style_options()
ConfigTestForm::form in core/modules/config/tests/config_test/src/ConfigTestForm.php
Gets the actual form array to be built.
ImageAdminStylesTest::testNumericStyleName in core/modules/image/tests/src/Functional/ImageAdminStylesTest.php
Tests creating an image style with a numeric name.
ImageFormatter::settingsForm in core/modules/image/src/Plugin/Field/FieldFormatter/ImageFormatter.php
Returns a form to configure settings for the formatter.
ImageFormatter::settingsSummary in core/modules/image/src/Plugin/Field/FieldFormatter/ImageFormatter.php
Returns a short summary for the current formatter settings.
ImageStyleDeleteForm::getReplacementOptions in core/modules/image/src/Form/ImageStyleDeleteForm.php
Returns a list of image style replacement options.

... See full list

File

core/modules/image/image.module, line 212

Code

function image_style_options($include_empty = TRUE) {
    $styles = ImageStyle::loadMultiple();
    $options = [];
    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;
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.