You are here

public static function JuiceboxFieldFormatter::defaultSettings in Juicebox HTML5 Responsive Image Galleries 8.2

Same name and namespace in other branches
  1. 8.3 src/Plugin/Field/FieldFormatter/JuiceboxFieldFormatter.php \Drupal\juicebox\Plugin\Field\FieldFormatter\JuiceboxFieldFormatter::defaultSettings()

Defines the default settings for this plugin.

Return value

array A list of default settings, keyed by the setting name.

Overrides PluginSettingsBase::defaultSettings

File

src/Plugin/Field/FieldFormatter/JuiceboxFieldFormatter.php, line 94

Class

JuiceboxFieldFormatter
Plugin implementation of the 'juicebox' formatter.

Namespace

Drupal\juicebox\Plugin\Field\FieldFormatter

Code

public static function defaultSettings() {

  // This is a static method so we can't use the injected JuiceboxFormatter
  // service. Instead we must get our own from the container.
  $juicebox = \Drupal::service('juicebox.formatter');
  $library = $juicebox
    ->getLibrary();
  return [
    // If the library supports multi-size we can default to that for the
    // main image, otherwise use the "medium" style.
    'image_style' => !empty($library['version']) && !in_array('juicebox_multisize_image_style', $library['disallowed_conf']) ? 'juicebox_multisize' : 'juicebox_medium',
    'thumb_style' => 'juicebox_square_thumb',
    'caption_source' => '',
    'title_source' => '',
  ] + $juicebox
    ->confBaseOptions() + parent::defaultSettings();
}