function exif_custom_get_exif_fields in EXIF Custom 7
Parameters
string $uri: A file URL.
bool $concatenate_arrays: Whether or not to concatenate values or overwrite them.
Return value
array The fields extracted.
3 calls to exif_custom_get_exif_fields()
- exif_custom_new_map_form_submit in ./
exif_custom.add.inc - Form submission callback for exif_custom_new_map_form().
- exif_custom_process_entity in ./
exif_custom.module - Process a given entity to see if it has EXIF data to be saved.
- exif_display_form_file_entity_edit_alter in exif_display/
exif_display.module - Implements hook_form_FORM_ID_alter() for file_entity_edit().
File
- ./
exif_custom.module, line 300 - Primary hook implementations for EXIF Custom.
Code
function exif_custom_get_exif_fields($uri, $concatenate_arrays = TRUE) {
// Generate the absolute URL for the image just once.
if (variable_get('exif_custom_request_method', 'legacy') == 'legacy') {
$image_url = drupal_realpath($uri);
}
else {
$image_url = file_create_url($uri);
}
$fields = array();
// EXIF. Because there can be corrupt / incompatible data in the image, and
// it doesn't support stream options, throw away any error messages.
$exif = @exif_read_data($image_url, NULL, TRUE);
if (isset($exif) && is_array($exif)) {
foreach ($exif as $name => $section) {
foreach ($section as $key => $value) {
if ($concatenate_arrays && is_array($value)) {
$value = implode(', ', $value);
}
$fields['EXIF:' . $name . ':' . $key] = exif_custom_check_plain($value);
}
}
}
// XMP.
$fields = array_merge($fields, exif_custom_get_xmp($image_url));
// IPTC. This function doesn't support stream options so ignore any errors.
$size = @getimagesize($image_url, $info);
if (isset($info) && is_array($info)) {
foreach ($info as $block) {
$iptc = iptcparse($block);
if (!empty($iptc)) {
// IPTC:2#254 can contain name=value pairs.
if (isset($iptc['2#254']) && is_array($iptc['2#254'])) {
$i = 0;
foreach ($iptc['2#254'] as $iptc_field) {
$subfields = explode('=', $iptc_field);
$iptc['2#254.' . $subfields[0]] = $subfields[1];
}
unset($iptc['2#254']);
}
foreach ($iptc as $key => $value) {
if ($concatenate_arrays && is_array($value)) {
$value = implode(', ', $value);
}
$fields['IPTC:' . $key] = exif_custom_check_plain($value);
}
}
}
}
return $fields;
}