You are here

protected function InsertImageWidgetUtility::aggregateVariables in Insert 8

@inheritdoc

Parameters

string $styleName:

array $element:

string $fieldType:

Return value

array

Overrides InsertFileWidgetUtility::aggregateVariables

File

src/Utility/InsertImageWidgetUtility.php, line 222

Class

InsertImageWidgetUtility

Namespace

Drupal\insert\Utility

Code

protected function aggregateVariables($styleName, $element, $fieldType) {
  $vars = parent::aggregateVariables($styleName, $element, $fieldType);
  $vars['url_original'] = $vars['url'];
  $vars['link_to_original'] = $this
    ->hasInsertLinkedEffect($styleName);
  $style = ImageStyle::load($styleName);
  if ($style !== null) {

    /** @var File $file */
    $file = $vars['file'];
    $uri = $style
      ->buildUri($file
      ->getFileUri());
    $style
      ->createDerivative($file
      ->getFileUri(), $uri);
    $vars['url'] = $this
      ->aggregateUrl($uri, !!$element['#insert_absolute']);
    $vars['uuid'] = 'insert-' . $styleName . '-' . $vars['uuid'];
  }
  $vars['insert_absolute'] = !!$element['#insert_absolute'];
  return $vars;
}