You are here

function mediafront_get_node_field_value in MediaFront 7.2

Returns the field values for a node entity.

File

./mediafront.module, line 588

Code

function mediafront_get_node_field_value($entity, $field) {
  $values = array();

  // Get the field name.
  $field_name = $field['field'];

  // Check for a valid field
  if (isset($entity->{$field_name})) {

    // Get the type of this field.
    $type = gettype($entity->{$field_name});

    // If it isn't an object or an array, then just return the value.
    if ($type != 'array') {
      $values[] = $entity->{$field_name};
    }
    elseif ($items = field_get_items('node', $entity, $field_name)) {
      foreach ($items as $item) {
        if ($value = mediafront_get_node_field_instance_value($item)) {
          $values[] = $value;
        }
      }
    }
  }
  return $values;
}