function _videojs_find_image_fields in Video.js (HTML5 Video Player) 7.2
Finds image fields in the given entity and bundle.
Parameters
$field: Field definition of the video field, used to match image fields when this field is rendered using Views.
$entity_type: Entity type in which the image field must occur.
$bundle: Bundle in which the image field must occur.
Return value
Array of image field names.
1 call to _videojs_find_image_fields()
File
- ./
videojs.module, line 213 - Provides an HTML5-compatible with Flash-fallback video player.
Code
function _videojs_find_image_fields($field, $entity_type, $bundle) {
$imagefields = array();
// Determine the image fields that will be selectable.
if ($entity_type == 'ctools' && $bundle == 'ctools') {
// This is a fake instance (see ctools_fields_fake_field_instance()).
// This occurs for instance when this formatter is used in Views.
// Display all image fields in bundles that contain this field.
$otherfields = field_info_fields();
foreach ($otherfields as $otherfield) {
if ($otherfield['type'] == 'image' && !empty($otherfield['bundles'])) {
// Find a label by finding an instance label
$instancelabels = array();
$bundles_names = array();
foreach ($otherfield['bundles'] as $otherentitytype => $otherbundles) {
foreach ($otherbundles as $otherbundle) {
// Check if this image field appears in one of the video field bundles.
if (isset($field['bundles'][$otherentitytype]) && in_array($otherbundle, $field['bundles'][$otherentitytype])) {
$otherinstance = field_info_instance($otherentitytype, $otherfield['field_name'], $otherbundle);
$instancelabels[$otherinstance['label']] = isset($instancelabels[$otherinstance['label']]) ? $instancelabels[$otherinstance['label']] + 1 : 1;
$bundles_names[] = t('@entity:@bundle', array(
'@entity' => $otherentitytype,
'@bundle' => $otherbundle,
));
}
}
}
if (!empty($instancelabels)) {
arsort($instancelabels);
$instancelabel = key($instancelabels);
$imagefields[$otherfield['field_name']] = $instancelabel . ' — ' . t('Appears in: @bundles.', array(
'@bundles' => implode(', ', $bundles_names),
));
}
}
}
}
else {
$otherinstances = field_info_instances($entity_type, $bundle);
foreach ($otherinstances as $otherinstance) {
$otherfield = field_info_field_by_id($otherinstance['field_id']);
if ($otherfield['type'] == 'image') {
$imagefields[$otherinstance['field_name']] = $otherinstance['label'];
}
}
}
return $imagefields;
}