You are here

public function FilterResponsiveImageStyle::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/FilterResponsiveImageStyle.php, line 144
Contains \Drupal\inline_responsive_images\Plugin\Filter\FilterResponsiveImageStyle.

Class

FilterResponsiveImageStyle
Provides a filter to render inline images as responsive images.

Namespace

Drupal\inline_responsive_images\Plugin\Filter

Code

public function tips($long = FALSE) {
  if ($long) {
    $image_styles = \Drupal::entityTypeManager()
      ->getStorage('responsive_image_style')
      ->loadMultiple();
    $list = '<code>' . implode('</code>, <code>', array_keys($image_styles)) . '</code>';
    return $this
      ->t('<p>You can make images responsive by adding a <code>data-responsive-image-style</code> attribute, whose value is one of the responsive image style machine names: @responsive-image-style-machine-name-list.</p>', [
      '@responsive-image-style-machine-name-list' => $list,
    ]);
  }
  else {
    return $this
      ->t('You can make images responsive by adding a data-responsive-image-style attribute.');
  }
}