0

I have a bit of a tricky one.

A client of mine wants the IPTC keywords data within files to be searchable through the default EE simple search (or at least via a db query).

I have searched around and can't find anything that offers this, with channel images coming the closest, but it doesn't appear its possible to search the IPTC data, only display it in templates.

Is there a way I could run an extension after each file upload is complete? I could then build an extension which uses PHPs IPTC extraction and enter it in a database table.

If anyone has any ideas on this, I would be greatful to know, as I am slightly surprised this doesn't come up more often.

Thank you.

1

The problem is that File Manager isn't associated with search which only relates to entries, so when you add an image to an entry, only the URL is stored with the entry, therefore only the URL is included in the searching.

The simplest solution would be to use a matrix field for your file uploads and include a column for the IPTC keywords to be added manually.

For example, in the below grab I use matrix to store information relevant to an image (alt text, title, etc) and ensure that "Is field searchable?" and "Is col searchable?" are ticked...

enter image description here

UPDATE

The alternative is a big task! Search is performed by looking at the field_id_x columns in the channel_data table. So if you simply place the IPTC reference in there, it will conflict with the fieldtype or entry data (e.g. a wysiwyg field).

So you'd need an extension that fired when an entry was saved and used: entry_submission_absolute_end and publish_form_entry_data to capture the save. You'd then need to parse this data for the relevant image paths, read the image data extracting the IPTC information.

That's the easy bit.

Then you'd need a custom lookup table in the database to store this information and reference the entry ID and URL.

But all this is still not going to associate with the search process in EE - and that's a problem as there's only the ability to change the search results (channel_entries_query_result hook), not change the SQL used to search on. So you then have to rebuild the exp:channel:entries tag pair to customise the SQL, run the search and then tap into the channel class and manually trigger the entries method to parse the parameters and output.

If you were to do your own sql query to do the search output, you'd still need to have saved the IPTC data and need to parse the data on output and process any parameters associated with the normal channel:entries tag pair. Although your custom SQL could output a list of entry_id's that you could then pass to the channel:entries tag to let it parse the output for you.

It's no small effort, so paying a junior for data entry would look far more appealing :)

3
  • Hi Peter. Thanks for your reply. The problem is that defeats the point of adding your keywords in a photo editing program if you then have to add them again. This is the problem for my client. They will be adding a lot of images, and don't want to add them manually.
    – ccdavies
    Aug 2 '13 at 14:44
  • Have updated answer to explain the custom build alternative. Aug 2 '13 at 15:05
  • Thank you Peter. Your right this is a big task. I am considering going down the path of the query module and passing the entry ids over.
    – ccdavies
    Aug 2 '13 at 15:08
0

I'm not sure this needs to be this complex - but you might be better served with a better image storage mechanism. I believe you can achieve what you're after using the metadata capabilities of either Assets, from Pixel & Tonic, or Channel Images from DevDemon. If you can pull your IPTC keywords into a Channel entry field, you should be able to access them via search, or perhaps more easily using the excellent Low Search.

See also this great blog post from Low on EE searching, as well as this recent question that may help.

http://gotolow.com/blog/a-low-search-primer

Search on Assets (pixel & tonic) Meta Data

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.