You are here

public function FilterImageStyle::tips in Inline responsive images 8.2

Generates a filter's tip.

A filter's tips should be informative and to the point. Short tips are preferably one-liners.

@todo Split into getSummaryItem() and buildGuidelines().

Parameters

bool $long: Whether this callback should return a short tip to display in a form (FALSE), or whether a more elaborate filter tips should be returned for template_preprocess_filter_tips() (TRUE).

Return value

string|null Translated text to display as a tip, or NULL if this filter has no tip.

Overrides FilterBase::tips

File

src/Plugin/Filter/FilterImageStyle.php, line 133
Contains \Drupal\inline_responsive_images\Plugin\Filter\FilterImageStyle.

Class

FilterImageStyle
Provides a filter to render inline images as image styles.

Namespace

Drupal\inline_responsive_images\Plugin\Filter

Code

public function tips($long = FALSE) {
  if ($long) {
    $image_styles = \Drupal::entityTypeManager()
      ->getStorage('image_style')
      ->loadMultiple();
    $list = '<code>' . implode('</code>, <code>', array_keys($image_styles)) . '</code>';
    return $this
      ->t('
        <p>You can display images using a site-wide style by adding a <code>data-image-style</code> attribute, whose value is one of the image style machine names: !image-style-machine-name-list.</p>', array(
      '!image-style-machine-name-list' => $list,
    ));
  }
  else {
    return $this
      ->t('You can display images using site-wide styles by adding a data-image-style attribute.');
  }
}