function search_file_attachments_extract_exif in Search File Attachments 7
Extract IPTC metadata from image.
Parameters
object $file: The file object.
Return value
string The extracted IPTC content.
1 call to search_file_attachments_extract_exif()
- search_file_attachments_get_file_content in ./
search_file_attachments.inc - Extract the content of the given file.
File
- ./
search_file_attachments.inc, line 136 - Heler functions, to hold the .module file clean and smart.
Code
function search_file_attachments_extract_exif($file) {
$content = '';
$size = getimagesize(file_create_url($file->uri), $info);
if (isset($info['APP13'])) {
$iptc_raw = iptcparse($info['APP13']);
if (empty($iptc_raw)) {
return $content;
}
$tagmarker = search_file_attachments_exif_tagmarker();
$iptc = array();
foreach ($iptc_raw as $key => $value) {
// Add only values from the defined iptc fields.
if (array_key_exists($key, $tagmarker)) {
$iptc_field_value = array();
foreach ($value as $innerkey => $innervalue) {
$innervalue = trim($innervalue);
if (!empty($innervalue)) {
$iptc_field_value[] = $innervalue;
}
}
if (!empty($iptc_field_value)) {
$iptc[$tagmarker[$key]] = implode(', ', $iptc_field_value);
}
}
}
foreach ($iptc as $key => $value) {
$content .= " <strong>{$key}:</strong> {$value}";
}
$content = trim($content);
}
return $content;
}