You are here

function bg_image_get_fields_for_node_type in Background Images 6

Same name and namespace in other branches
  1. 7 bg_image.module \bg_image_get_fields_for_node_type()

Returns the fields for a given node type Only image fields will be accepted

1 call to bg_image_get_fields_for_node_type()
bg_image_settings_form in ./bg_image.module
Defines the settings for for bg_image

File

./bg_image.module, line 249
Allows for customizable background images per page

Code

function bg_image_get_fields_for_node_type($node_type) {

  // Array to hold our fields
  $fields = array();
  if ($node_type) {

    // Get all the fields for the content type. We'll use this to determine the field type
    $info = content_types($node_type);

    // Loop through the fields of the node type
    foreach ($info['fields'] as $field_name => $field) {

      // Check that it's an image field
      if ($field['module'] == 'filefield' && $field['widget']['module'] == 'imagefield') {

        // Add the item to our option list
        $fields[$field_name] = $field['widget']['label'];
      }
    }
  }

  // If there were no fields, we return a message
  if (!$fields) {
    $fields[''] = 'No image fields attached to this node type';
  }
  return $fields;
}