You are here

function fontawesome_iconpicker_field_formatter_view in Font Awesome Iconpicker 7

Implements hook_field_formatter_view().

File

./fontawesome_iconpicker.module, line 242
Integrates fontawesome-iconpicker plugin with Drupal.

Code

function fontawesome_iconpicker_field_formatter_view($entity_type, $entity, $field, $instance, $langcode, $items, $display) {
  $element = array();
  switch ($display['type']) {
    case 'fontawesome_iconpicker_icon':
      $size = $display['settings']['size'];
      foreach ($items as $key => $item) {
        $element[$key]['#markup'] = '<i class="fa ' . $item['safe_value'] . ' fa-' . $size . '" aria-hidden="true"></i>';
      }
      break;
  }
  return $element;
}