You are here

public function MarkerIconService::getImageStyleOptions in Geofield Map 8.2

Generate Image Style Selection Element.

Return value

array The Image Style Select element.

File

src/Services/MarkerIconService.php, line 389

Class

MarkerIconService
Provides an Icon Managed File Service.

Namespace

Drupal\geofield_map\Services

Code

public function getImageStyleOptions() {
  $options = [
    'none' => $this
      ->t('<- Original File ->'),
  ];
  if ($this->moduleHandler
    ->moduleExists('image')) {

    // Always force the definition of the geofield_map_default_icon_style,
    // if not present.
    if (!ImageStyle::load('geofield_map_default_icon_style')) {
      try {
        $this
          ->setDefaultIconStyle();
      } catch (ParseException $e) {
      }
    }
    $image_styles = ImageStyle::loadMultiple();

    /* @var \Drupal\image\ImageStyleInterface $style */
    foreach ($image_styles as $k => $style) {
      $options[$k] = Unicode::truncate($style
        ->label(), 20, TRUE, TRUE);
    }
  }
  return $options;
}