You are here

function fontawesome_preprocess_icon_sprite in Font Awesome Icons 7.3

Same name and namespace in other branches
  1. 8.2 fontawesome.module \fontawesome_preprocess_icon_sprite()
  2. 8 fontawesome.module \fontawesome_preprocess_icon_sprite()
  3. 7 fontawesome.module \fontawesome_preprocess_icon_sprite()
  4. 7.2 fontawesome.module \fontawesome_preprocess_icon_sprite()

Implements hook_preprocess_icon_RENDER_HOOK().

File

./fontawesome.module, line 539
Drupal integration with Font Awesome 5.

Code

function fontawesome_preprocess_icon_sprite(&$variables) {
  $bundle =& $variables['bundle'];
  if ($bundle['provider'] === FONTAWESOME_LIBRARY) {

    // Remove the default "icon" class.
    $key = array_search('icon', $variables['attributes']['class']);
    if ($key !== FALSE) {
      unset($variables['attributes']['class'][$key]);
    }

    // Add the necessary FA identifier class.
    $variables['attributes']['class'][] = FONTAWESOME_PREFIX;

    // Prepend the icon with the FA prefix (which will be used as the class).
    $variables['icon'] = FONTAWESOME_PREFIX . '-' . $variables['icon'];
  }
}