You are here

function _magnific_popup_thumbnail_field_options in Magnific Popup 7

Utility function returning all possible thumbnail fields.

A field is considered a potential thumbnail field if its type is "image" or "file".

Parameters

array $all_fields: An array of all fields on the entity.

string $field_bundle: The entity's bundle machine name.

Return value

array An associative array of field machine names (keys) and labels (values).

1 call to _magnific_popup_thumbnail_field_options()
magnific_popup_field_formatter_settings_form in includes/magnific_popup.formatters.inc
Implements hook_field_formatter_settings_form().

File

includes/magnific_popup.formatters.inc, line 348
Formatters for Magnific Popup.

Code

function _magnific_popup_thumbnail_field_options($all_fields, $field_bundle) {
  $file_fields = array();
  if (!empty($all_fields)) {
    foreach ($all_fields as $field_name) {
      $field_info = field_info_field($field_name);
      if ($field_info['type'] == 'file' || $field_info['type'] == 'image') {
        $file_field = field_info_instance('node', $field_name, $field_bundle);
        if (!empty($file_field['label']) && !empty($file_field['field_name'])) {
          $file_fields[$file_field['field_name']] = $file_field['label'];
        }
      }
    }
  }
  return $file_fields;
}