public function LazyFilter::tips in Lazy-load 8.3
Same name and namespace in other branches
- 8 src/Plugin/Filter/LazyFilter.php \Drupal\lazy\Plugin\Filter\LazyFilter::tips()
- 8.2 src/Plugin/Filter/LazyFilter.php \Drupal\lazy\Plugin\Filter\LazyFilter::tips()
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/ LazyFilter.php, line 196
Class
- LazyFilter
- Provides a filter to lazy-load images.
Namespace
Drupal\lazy\Plugin\FilterCode
public function tips($long = FALSE) {
$tags = [
'img' => $this->settings['image'],
'iframe' => $this->settings['iframe'],
];
$options = [
'%img' => '<img>',
'%iframe' => '<iframe>',
];
$skip_class = $this->configFactory
->get('lazy.settings')
->get('skipClass');
$skip_help = $this
->t('If you want certain elements skip lazy-loading, add <code>%skip_class</code> class name.', [
'%skip_class' => $skip_class,
]);
if (!empty($tags)) {
if ($tags['img'] && $tags['iframe']) {
return $this
->t('Lazy-loading is enabled for both %img and %iframe tags.', $options) . ' ' . $skip_help;
}
if ($tags['img']) {
return $this
->t('Lazy-loading is enabled for %img tags.', $options) . ' ' . $skip_help;
}
if ($tags['iframe']) {
return $this
->t('Lazy-loading is enabled for %iframe tags.', $options) . ' ' . $skip_help;
}
}
return $this
->t('Lazy-loading is not enabled.');
}