You are here

protected function FontAwesomeIconMedia::getThumbnail in Font Awesome Icons 8.2

Gets the thumbnail image URI based on an icon entity.

Parameters

\Drupal\fontawesome\Plugin\Field\FieldType\FontAwesomeIcon $icon: A Font Awesome Icon entity.

Return value

string File URI of the thumbnail image or NULL if there is no specific icon.

1 call to FontAwesomeIconMedia::getThumbnail()
FontAwesomeIconMedia::getMetadata in modules/fontawesome_media/src/Plugin/media/Source/FontAwesomeIconMedia.php
Gets the value for a metadata attribute for a given media item.

File

modules/fontawesome_media/src/Plugin/media/Source/FontAwesomeIconMedia.php, line 69

Class

FontAwesomeIconMedia
Media source wrapping around a Font Awesome icon field.

Namespace

Drupal\fontawesome_media\Plugin\media\Source

Code

protected function getThumbnail(FontAwesomeIcon $icon) {

  // Determine the source folder.
  switch ($icon
    ->get('style')
    ->getValue()) {
    case 'fab':
      $srcFolder = 'brands';
      break;
    case 'fal':
      $srcFolder = 'light';
      break;
    case 'fas':
      $srcFolder = 'solid';
      break;
    case 'far':
    default:
      $srcFolder = 'regular';
      break;
    case 'fad':
      $srcFolder = 'duotone';
      break;
    case 'fak':
      $srcFolder = 'kit';
      break;
  }
  return 'libraries/fontawesome/svgs/' . $srcFolder . '/' . $icon
    ->get('icon_name')
    ->getValue() . '.svg';
}