aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSilvio <s1lv10@uol.com.br>2010-04-27 18:10:58 -0300
committerSilvio <s1lv10@uol.com.br>2010-04-27 18:10:58 -0300
commit0d60e32584aeb64d0f4b8844c5ef49e57a0eada2 (patch)
tree06b63c4d210442df10ac7543dbad9f1bbebf0b82
parent46ba9330eeb9a0c46af5785d784499c6a4c6c614 (diff)
downloadexif-0d60e32584aeb64d0f4b8844c5ef49e57a0eada2.tar.gz
exif-0d60e32584aeb64d0f4b8844c5ef49e57a0eada2.tar.bz2
Checking namespace availability before asking for metadata
-rw-r--r--exif.class.php26
1 files changed, 14 insertions, 12 deletions
diff --git a/exif.class.php b/exif.class.php
index 62f01c5..3913927 100644
--- a/exif.class.php
+++ b/exif.class.php
@@ -173,6 +173,9 @@ Class Exif {
// Get XMP metadata into the object.
if ($xmpfiles->GetXMP($xmpmeta)) {
+ // Sort metadata.
+ $xmpmeta->Sort();
+
return array('files' => $xmpfiles, 'meta' => $xmpmeta);
}
@@ -210,18 +213,17 @@ Class Exif {
$xmpfiles = $xmp['files'];
$xmpmeta = $xmp['meta'];
- // Sort.
- $xmpmeta->Sort();
-
- // Read XMP data.
- if ($config['type'] == 'property') {
- $value = @$xmpmeta->GetProperty($config['name'], $config['ns']);
- }
- elseif ($config['type'] == 'array') {
- $value = @$xmpmeta->GetArrayItem($config['name'], $key, $config['ns']);
- }
- elseif ($config['type'] == 'struct') {
- $value = @$xmpmeta->GetStructField($config['ns'], $config['struct'], $config['ns'], $config['name']);
+ // Try to read XMP data if the namespace is available.
+ if(@$xmpmeta->GetNamespacePrefix($config['ns'])) {
+ if ($config['type'] == 'property') {
+ $value = @$xmpmeta->GetProperty($config['name'], $config['ns']);
+ }
+ elseif ($config['type'] == 'array') {
+ $value = @$xmpmeta->GetArrayItem($config['name'], $key, $config['ns']);
+ }
+ elseif ($config['type'] == 'struct') {
+ $value = @$xmpmeta->GetStructField($config['ns'], $config['struct'], $config['ns'], $config['name']);
+ }
}
return $value;