Skip to content

Instantly share code, notes, and snippets.

@Greg-Boggs
Created September 9, 2013 18:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Greg-Boggs/6499221 to your computer and use it in GitHub Desktop.
Save Greg-Boggs/6499221 to your computer and use it in GitHub Desktop.
<?php
elseif ($image_link) {
if (isset($entity->$image_link)) {
// Support for field translations.
$language = field_language($entity_type, $entity, $field['field_name']);
$link_field = $entity->$image_link;
if (isset($link_field[$language])) {
$link_values = $link_field[$language];
}
}
}
// are these the same?
// Handle multiple link with image values.
if (!empty($link_values)) {
if (isset($link_values[$delta]['url'])) {
$uri = array(
'path' => $link_values[$delta]['url'],
'options' => array('attributes' => $link_values[$delta]['attributes']),
);
// Handle query if there is any.
if (!empty($link_values[$delta]['query'])) {
$uri['options']['query'] = $link_values[$delta]['query'];
}
// Handle fragment if there is any.
if (!empty($link_values[$delta]['fragment'])) {
$uri['options']['fragment'] = $link_values[$delta]['fragment'];
}
}
// If there are more image values than link values unset the link.
else {
unset($uri);
}
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment