1 views_handler_field_file_icon.inc protected views_handler_field_file_icon::renderImg($icon_name, $extension)

Render the icon as img tag.

File

core/modules/file/views/views_handler_field_file_icon.inc, line 99
Definition of views_handler_field_file_icon.

Class

views_handler_field_file_icon

Code

protected function renderImg($icon_name, $extension) {
  $attributes = array(
    'width' => $this->options['icon_size'],
    'height' => $this->options['icon_size'],
    'alt' => '',
    'src' => base_path() . icon_get_path($icon_name),
  );
  if ($this->options['add_alt_text']) {
    $attributes['alt'] = t('File icon for @extension extension', array(
      '@extension' => $extension,
    ));
  }
  else {
    // Add aria-hidden if this is a purely decorative situation.
    // See https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Attributes/aria-hidden
    $attributes['aria-hidden'] = 'true';
  }
  return '<img ' . backdrop_attributes($attributes) . '>';
}