[SOLVED] Need to add IPTC info to end of Description field on import

Another_Matt

Joined: 2009-08-20
Posts: 33
Posted: Thu, 2009-10-29 23:50

I'm trying to figure out how to add IPTC/City & IPTC/State info to the end of my description on image import. Basically I want my location info searchable in the database. Is it possible to import three fields into one? I think the answer lies in EXIF/ExifDescriptionOption.inc around #115 but I can't figure it out. Can someone help with the code? Here's the original.

Quote:
$itemDescription = '';
if (!empty($exifData[$itemId]['IPTC/Caption']['value'])) {
$itemDescription = $exifData[$itemId]['IPTC/Caption']['value'];
}
else if (!empty($exifData[$itemId]['ImageDescription']['value'])) {
$itemDescription = $exifData[$itemId]['ImageDescription']['value'];
}
else if (!empty($exifData[$itemId]['UserComment']['value'])) {
$itemDescription = $exifData[$itemId]['UserComment']['value'];
}

Thanks. -Matt

Login or register to post comments
Another_Matt

Joined: 2009-08-20
Posts: 33
Posted: Sat, 2009-10-31 01:39

Can I use CONCAT for this? I need ['IPTC/City']','['IPTC/ProvinceState'] at the end of ['IPTC/Caption'].

Any guidance on this is really appreciated.

Login or register to post comments
nivekiam
nivekiam's picture

Joined: 2002-12-10
Posts: 9283
Posted: Mon, 2009-11-02 23:31
Quote:
Basically I want my location info searchable in the database

AFAIK, the EXIF/IPTC info is not stored in the database and actually read every time the image is loaded. Which is one reason it's advised to not use the EXIF module on a heavily trafficked site as it will become a huge performance hit.
____________________________________________
Like Gallery? Like the support? Donate now!!! See G2 live here

Login or register to post comments
nivekiam
nivekiam's picture

Joined: 2002-12-10
Posts: 9283
Posted: Mon, 2009-11-02 23:35

Oh wait, I think I see what you're doing. So you're having that info imported into Gallery's description? I don't know the best approach to do that in the code.

I don't think you can use "CONCAT" for that as I don't think it's a valid PHP function, but...
http://php.net/manual/en/language.operators.string.php

____________________________________________
Like Gallery? Like the support? Donate now!!! See G2 live here

Login or register to post comments
Another_Matt

Joined: 2009-08-20
Posts: 33
Posted: Tue, 2009-11-03 01:15

That's what I'm looking for! I added a condition to grab the city & state info unless it's empty. Here's my change for the curious. Line #64 of ExifDescriptionOption.inc
Add

Quote:
$needed[] = 'IPTC/City';
$needed[] = 'IPTC/ProvinceState';

Line #117 change

Quote:
$itemDescription = '';
if (!empty($exifData[$itemId]['IPTC/City']['value'])) {
$itemDescription = $exifData[$itemId]['IPTC/Caption']['value'] . "-" . $exifData[$itemId]['IPTC/City']['value'] . ", " . $exifData[$itemId]['IPTC/ProvinceState']['value'];
}
else if (!empty($exifData[$itemId]['IPTC/Caption']['value'])) {
$itemDescription = $exifData[$itemId]['IPTC/Caption']['value'];
}
else if (!empty($exifData[$itemId]['ImageDescription']['value'])) {
$itemDescription = $exifData[$itemId]['ImageDescription']['value'];
}
else if (!empty($exifData[$itemId]['UserComment']['value'])) {
$itemDescription = $exifData[$itemId]['UserComment']['value'];
}

Thanks for the help. Works great in the search.

Login or register to post comments