You are here

function _linkimagefield_format_set_attribute in Link Image Field 7

Determine whether an attribute for the link should be the default or the custom.

Works for a url, alt or title attribute.

Parameters

string $attr:

array $item:

array $instance:

1 call to _linkimagefield_format_set_attribute()
linkimagefield_field_formatter_view in ./linkimagefield.module
Implements hook_field_formatter_view().

File

./linkimagefield.module, line 445
Defines a link image field type.

Code

function _linkimagefield_format_set_attribute($attr, &$item, $instance) {
  $default_value = !empty($instance['settings'][$attr]) ? $instance['settings'][$attr] : !empty($instance['settings']['url_settings'][$attr]) ? $instance['settings']['url_settings'][$attr] : '';
  if (empty($item[$attr]) && !empty($default_value)) {
    $item[$attr] = $default_value;
  }
}