Announcement

  •  » Extensions
  •  » Triggers to use to add new keywords on import?

#1 2019-08-14 01:05:17

dd-b
Member
2018-04-16
28

Triggers to use to add new keywords on import?

The specific question is, what triggers should I be attaching my import functions to?  Putting that first, so we don't get side-tracked on other issues.  Obvious keyword searches on the list of triggers didn't find anything that looked right, and checking the facetag plugin didn't show me how to do this.

What the plugin is supposed to do is, whenever an image is initially imported or resynchronized (either by FTP resync or by HTML upload including automatic resync when the image is replaced), it will create tags based on various fields in the IPTC or EXIF data (in addition to the tags core code already creates from the keywords field in the IPTC data).  These should then get stored in the database, and appear whenever a list of tags is extracted, and be searchable in searches like other tags, and so forth, just like "real" keywords.  If I can get control at the right point, and add my new virtual keywords into the existing list of keywords, this should work, right? 

So...does somebody know off the top of their head the trigger I should be hooking myself to, or have ideas for how to find out?  I'll find it eventually just from the code, but saving time would be nice.  I suppose there might be two, three, or four triggers (could be resync, initial html upload, html replacement, say, separately) I needed to hook to?

    Piwigo 2.9.5
    Operating system: Linux
    PHP: 7.0.33 (Show info) [2019-08-13 16:03:14]
    MySQL: 5.7.25-log [2019-08-13 16:03:14]
    Graphics Library: ImageMagick 6.9.7-4

Offline

 

#2 2019-08-14 04:47:17

dd-b
Member
2018-04-16
28

Re: Triggers to use to add new keywords on import?

Okay, I finally found out how to get the Trigger Trace plugin to show its data (why isn't this in the plugin description???). And ran a manual reconcile with Trigger Trace on.

And oh dear.  It looks like there actually [i]isn't[i] a trigger that gets called when a photo is being imported or synchronized?  Can this be right?   

Can we fix it?  I haven't actually found the code that does that yet (was expecting identifying the trigger to lead me to the code, oops).

Offline

 

#3 2019-08-14 20:02:51

executive
Member
2017-08-16
616

Re: Triggers to use to add new keywords on import?

There is some useful stuff in the documentation:
https://piwigo.org/doc/doku.php?id=dev:extensions:start

The best way to learn about making an extension is to look at examples.
For example the "ImageMagick_GPS" extension has event handlers on import.

Offline

 

#4 2019-08-14 20:14:57

dd-b
Member
2018-04-16
28

Re: Triggers to use to add new keywords on import?

I've been through those doc examples, and they did help a lot. Got me started, pointed me at some tools. 

Thanks very much for the example of the Image Magick GPS extension, I'll go look at that!

Offline

 

#5 2019-08-14 20:34:42

dd-b
Member
2018-04-16
28

Re: Triggers to use to add new keywords on import?

So the only trigger Image Magick GPS hooks is "format_exif_data" -- whose name made it clear it doesn't do what I was looking for.  Sigh.  I haven't found another example calling it -- and I haven't found where in the core code it is called

Shouldn't that string, "format_exif_data", show up where the core code checks to see if anything is on that hook? 

I guess I'll dig after how those are called some other way since the obvious way isn't working.  (I'm assuming that hook *does* do what I'm looking for; don't see how this plugin could do what it does without doing that in a trigger somewhere and that's the only trigger it hooks so it has to be there. And the arguments make it possible.)

Or...what's the good way to find where core code calls any particular trigger?

Offline

 

#6 2019-08-14 22:20:23

executive
Member
2017-08-16
616

Re: Triggers to use to add new keywords on import?

Offline

 
  •  » Extensions
  •  » Triggers to use to add new keywords on import?

Board footer

Powered by FluxBB

github twitter facebook google+ newsletter Donate Piwigo.org © 2002-2019 · Contact