You are here

function imageapi_optimize_pipeline_options in Image Optimize (or ImageAPI Optimize) 8.2

Same name and namespace in other branches
  1. 8.3 imageapi_optimize.module \imageapi_optimize_pipeline_options()
  2. 7.2 imageapi_optimize.module \imageapi_optimize_pipeline_options()
  3. 4.x imageapi_optimize.module \imageapi_optimize_pipeline_options()

Gets an array of image pipelines 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 pipelines both key and value are set to pipeline name.

4 calls to imageapi_optimize_pipeline_options()
ImageAPIOptimizeDefaultPipelineConfigForm::buildForm in src/Form/ImageAPIOptimizeDefaultPipelineConfigForm.php
Form constructor.
ImageAPIOptimizeHookImplementations::form_image_style_edit_form_alter in src/ImageAPIOptimizeHookImplementations.php
Implements hook_form_image_style_edit_form_alter().
ImageAPIOptimizePipelineDeleteForm::getReplacementOptions in src/Form/ImageAPIOptimizePipelineDeleteForm.php
Returns a list of image optimize pipeline replacement options.
ImageStyleWithPipelineListBuilder::buildRow in src/ImageStyleWithPipelineListBuilder.php
Builds a row for an entity in the entity listing.

File

./imageapi_optimize.module, line 19

Code

function imageapi_optimize_pipeline_options($include_empty = TRUE, $include_site_default = TRUE) {
  $pipelines = ImageAPIOptimizePipeline::loadMultiple();
  $options = [];
  if ($include_empty && !empty($pipelines)) {
    $options[''] = t('- None -');
  }
  if ($include_site_default && !empty($pipelines)) {
    if ($default_pipeline_name = \Drupal::config('imageapi_optimize.settings')
      ->get('default_pipeline')) {
      if ($default_pipeline = ImageAPIOptimizePipeline::load($default_pipeline_name)) {
        $options['__default__'] = t('Sitewide default pipeline: @name', [
          '@name' => $default_pipeline
            ->label(),
        ]);
      }
    }
  }
  foreach ($pipelines as $name => $pipeline) {
    $options[$name] = $pipeline
      ->label();
  }
  if (empty($options)) {
    $options[''] = t('No defined pipelines');
  }
  return $options;
}