public function LazyFilter::tips in Lazy-load 8
Same name and namespace in other branches
- 8.3 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 82
Class
- LazyFilter
- Provides a filter to lazy-load images.
Namespace
Drupal\lazy\Plugin\FilterCode
public function tips($long = FALSE) {
$tags = \Drupal::config('lazy.blazy')
->get('alter_tag');
$tags = implode(' ', $tags);
$tags = trim(str_replace([
'0',
], '', $tags));
$options = [
'%img' => '<img>',
'%iframe' => '<iframe>',
];
switch ($tags) {
case 'img':
return t('%img elements are lazy-loaded.', $options);
case 'iframe':
return t('%iframe elements are lazy-loaded.', $options);
case 'img iframe':
default:
return t('Both %img and %iframe elements are lazy-loaded.', $options);
}
}