function rdf_preprocess_field
rdf_preprocess_field(&$variables)
Implements MODULE_preprocess_HOOK().
File
- modules/rdf/rdf.module, line 543
- Enables semantically enriched output for Drupal sites in the form of RDFa.
Code
function rdf_preprocess_field(&$variables) { $element = $variables['element']; $mapping = rdf_mapping_load($element['#entity_type'], $element['#bundle']); $field_name = $element['#field_name']; if (!empty($mapping) && !empty($mapping[$field_name])) { foreach ($element['#items'] as $delta => $item) { $variables['item_attributes_array'][$delta] = rdf_rdfa_attributes($mapping[$field_name], $item); // If this field is an image, RDFa will not output correctly when the // image is in a containing <a> tag. If the field is a file, RDFa will // not output correctly if the filetype icon comes before the link to the // file. We correct this by adding a resource attribute to the div if // this field has a URI. if (isset($item['uri'])) { if (!empty($element[$delta]['#image_style'])) { $variables['item_attributes_array'][$delta]['resource'] = image_style_url($element[$delta]['#image_style'], $item['uri']); } else { $variables['item_attributes_array'][$delta]['resource'] = file_create_url($item['uri']); } } } } }
© 2001–2016 by the original authors
Licensed under the GNU General Public License, version 2 and later.
Drupal is a registered trademark of Dries Buytaert.
https://api.drupal.org/api/drupal/modules!rdf!rdf.module/function/rdf_preprocess_field/7.x