mirror of
https://github.com/alchemy-fr/Phraseanet.git
synced 2025-10-23 09:53:15 +00:00
Merge pull request #2582 from aynsix/PHRAS-2031-porting-Add-xmpmm-documentId
PHRAS-2031 Port to 4.1 - Add XmpMM:DocumentID source
This commit is contained in:
@@ -49,6 +49,7 @@ class File
|
||||
protected $originalName;
|
||||
protected $md5;
|
||||
protected $attributes;
|
||||
public static $xmpTag = ['XMP-xmpMM:DocumentID'];
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
@@ -102,6 +103,7 @@ class File
|
||||
'IPTC:UniqueDocumentID',
|
||||
'ExifIFD:ImageUniqueID',
|
||||
'Canon:ImageUniqueID',
|
||||
'XMP-xmpMM:DocumentID',
|
||||
];
|
||||
|
||||
if (!$this->uuid) {
|
||||
@@ -112,6 +114,9 @@ class File
|
||||
foreach ($availableUUIDs as $meta) {
|
||||
if ($metadatas->containsKey($meta)) {
|
||||
$candidate = $metadatas->get($meta)->getValue()->asString();
|
||||
if(in_array($meta, self::$xmpTag)){
|
||||
$candidate = self::sanitizeXmpUuid($candidate);
|
||||
}
|
||||
if (Uuid::isValid($candidate)) {
|
||||
$uuid = $candidate;
|
||||
break;
|
||||
@@ -287,4 +292,13 @@ class File
|
||||
|
||||
return new File($app, $media, $collection, $originalName);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sanitize XMP UUID
|
||||
* @param $uuid
|
||||
* @return mixed
|
||||
*/
|
||||
public static function sanitizeXmpUuid($uuid){
|
||||
return str_replace('xmp.did:', '', $uuid);
|
||||
}
|
||||
}
|
||||
|
@@ -11,6 +11,7 @@
|
||||
|
||||
namespace Alchemy\Phrasea\Metadata;
|
||||
|
||||
use Alchemy\Phrasea\Border\File;
|
||||
use Alchemy\Phrasea\Databox\DataboxRepository;
|
||||
use Alchemy\Phrasea\Metadata\Tag\NoSource;
|
||||
use PHPExiftool\Driver\Metadata\Metadata;
|
||||
@@ -119,8 +120,11 @@ class PhraseanetMetadataSetter
|
||||
if (!isset($metadataPerField[$fieldName])) {
|
||||
$metadataPerField[$fieldName] = [];
|
||||
}
|
||||
|
||||
$metadataPerField[$fieldName] = array_merge($metadataPerField[$fieldName], $metadata->getValue()->asArray());
|
||||
if(in_array($tagName, File::$xmpTag)){
|
||||
$metadataPerField[$fieldName] = array_merge($metadataPerField[$fieldName], (array) File::sanitizeXmpUuid($metadata->getValue()->asString()));
|
||||
}else{
|
||||
$metadataPerField[$fieldName] = array_merge($metadataPerField[$fieldName], $metadata->getValue()->asArray());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user