function font_reference_field_formatter_view in @font-your-face 7
Same name and namespace in other branches
- 7.2 modules/font_reference/font_reference.module \font_reference_field_formatter_view()
Implements hook_field_formatter_view().
File
- modules/
font_reference/ font_reference.module, line 153 - Defines a field type for referencing a font from a node.
Code
function font_reference_field_formatter_view($entity_type, $entity, $field, $instance, $langcode, $items, $display) {
$result = array();
switch ($display['type']) {
case 'font_reference_default':
foreach ($items as $delta => $item) {
if ($field['settings']['css_selector'] != '') {
$font = fontyourface_get_font($item['fid']);
$css = $field['settings']['css_selector'] . ' { ' . fontyourface_font_css($font) . ' }';
drupal_add_css($css, array(
'type' => 'inline',
));
}
// if
}
// foreach
break;
case 'font_reference_name':
foreach ($items as $delta => $item) {
$font = fontyourface_get_font($item['fid']);
$result[$delta] = array(
'#markup' => check_plain($font->name),
);
if ($field['settings']['css_selector'] != '') {
$css = $field['settings']['css_selector'] . ' { ' . fontyourface_font_css($font) . ' }';
drupal_add_css($css, array(
'type' => 'inline',
));
}
// if
}
// foreach
break;
}
// switch
return $result;
}