You are here

protected function SvgFormatter::generateAltAttribute in SVG Formatter 8

Generates alt attribute from an image filename.

1 call to SvgFormatter::generateAltAttribute()
SvgFormatter::viewElements in src/Plugin/Field/FieldFormatter/SvgFormatter.php
Builds a renderable array for a field value.

File

src/Plugin/Field/FieldFormatter/SvgFormatter.php, line 342

Class

SvgFormatter
Plugin implementation of the 'svg_formatter' formatter.

Namespace

Drupal\svg_formatter\Plugin\Field\FieldFormatter

Code

protected function generateAltAttribute($filename) {
  $alt = str_replace([
    '.svg',
    '-',
    '_',
  ], [
    '',
    ' ',
    ' ',
  ], $filename);
  $alt = ucfirst($alt);
  return $alt;
}