private function SvgImageFieldFormatter::generateAltAttribute in SVG Image Field 8
Same name and namespace in other branches
- 2.1.x src/Plugin/Field/FieldFormatter/SvgImageFieldFormatter.php \Drupal\svg_image_field\Plugin\Field\FieldFormatter\SvgImageFieldFormatter::generateAltAttribute()
- 2.0.x src/Plugin/Field/FieldFormatter/SvgImageFieldFormatter.php \Drupal\svg_image_field\Plugin\Field\FieldFormatter\SvgImageFieldFormatter::generateAltAttribute()
Generate alt attribute from an image filename.
1 call to SvgImageFieldFormatter::generateAltAttribute()
- SvgImageFieldFormatter::viewElements in src/
Plugin/ Field/ FieldFormatter/ SvgImageFieldFormatter.php - Builds a renderable array for a field value.
File
- src/
Plugin/ Field/ FieldFormatter/ SvgImageFieldFormatter.php, line 231
Class
- SvgImageFieldFormatter
- Plugin implementation of the 'svg_formatter' formatter.
Namespace
Drupal\svg_image_field\Plugin\Field\FieldFormatterCode
private function generateAltAttribute($filename) {
$alt = str_replace([
'.svg',
'-',
'_',
], [
'',
' ',
' ',
], $filename);
$alt = ucfirst($alt);
return $alt;
}