function imageinfo_cache_get_all_images_in_field in Imageinfo Cache 7.3
Given a field name get all image uri's in it.
Parameters
array $image_fields: Array of image fields from imageinfo_cache_get_image_fields().
string $field_name: Name of field.
Return value
array Array of files attached to this field.
2 calls to imageinfo_cache_get_all_images_in_field()
- drush_imageinfo_cache_image_generate in ./
imageinfo_cache.drush.inc - Drush callback.
- imageinfo_cache_get_all_images_in_all_fields in ./
imageinfo_cache.drush.inc - Given a list of image_fields get all image uri's in them.
File
- ./
imageinfo_cache.drush.inc, line 155 - Image module's drush integration.
Code
function imageinfo_cache_get_all_images_in_field(array $image_fields, $field_name) {
$fids = array();
foreach ($image_fields[$field_name]['#field_info'] as $field_values) {
$query = new ApachesolrAttachmentsEntityFieldQuery();
$results = $query
->entityCondition('entity_type', $field_values['entity_type'], '=')
->entityCondition('bundle', $field_values['bundle'])
->fieldCondition($field_name, 'fid', NULL, 'IS NOT NULL')
->deleted(FALSE)
->addExtraField($field_name, 'fid', 'fid')
->execute();
if (!empty($results[$field_values['entity_type']])) {
foreach ($results[$field_values['entity_type']] as $key => $value) {
if (!empty($value->extraFields->{$field_name . '_fid'}) && is_numeric($value->extraFields->{$field_name . '_fid'})) {
$fids[$key] = $value->extraFields->{$field_name . '_fid'};
}
}
}
}
$files = array();
if (!empty($fids)) {
$files = db_select('file_managed', 'fm')
->fields('fm', array(
'fid',
'uri',
))
->condition('status', 1, '=')
->condition('fid', $fids, 'IN')
->execute()
->fetchAllKeyed();
}
return $files;
}