You are here

public function InsertImageWidgetUtility::render in Insert 8

@inheritdoc

Overrides InsertFileWidgetUtility::render

File

src/Utility/InsertImageWidgetUtility.php, line 192

Class

InsertImageWidgetUtility

Namespace

Drupal\insert\Utility

Code

public function render($styleName, $vars) {
  if ($styleName == 'icon_link') {
    $rendered = \Drupal::theme()
      ->render([
      'insert_icon_link',
    ], $vars);
  }
  elseif ($styleName === 'link') {
    $rendered = \Drupal::theme()
      ->render([
      'insert_link',
    ], $vars);
  }
  else {
    $rendered = \Drupal::theme()
      ->render([
      'insert_image__' . str_replace('-', '_', $styleName),
      'insert_image',
    ], $vars);
  }
  return gettype($rendered) === 'string' ? $rendered : $rendered
    ->jsonSerialize();
}