Announcement

  •  » Extensions
  •  » Intentions for new plugin -- importing various metadata as keywords

#1 2020-09-17 22:28:40

dd-b
Member
2018-04-16
60

Intentions for new plugin -- importing various metadata as keywords

Is this something that is best done in a plugin?  I started out playing with the idea by modifying the core code in my installation, enough to verify that I can kind of make the idea work. However, in the long run that means blocking automatic upgrades and doing work to make sure I propagate my changes forward each time I update manually, and that is going to be a lot of work, and I probably won't update as often because of it so I'll more vulnerable to bugs and hacks too; whereas a plugin largely frees me from that problem I believe; it might have to be upgraded when core changes enough, but then modifications to core code might also.

What I want to do is bring in various metadata fields as specially-formatted keywords. For example, I will bring in the city field (if the value is Minneapolis for example) as the keyword "city:Minneapolis". In addition, I have a convention where the supplemental categories fields can contain information of the form "name=value" (for certain specific names; for example, "FILM=KODAK TRI_X", or "SFCON=MINICON 7"), and I want to import those as keywords also, probably reformatting them to use colon instead of equals.

(If I get the basic thing working, I have some vague ideas of adding a management page that might make it of interest to people beyond me. While I have no problem sharing my work on this, at least the early versions are going to have hard-coded my own particular bizarre requirements.)

I'm also interested possibly in *reversing* the process -- when something like write metadata is triggered (but my own version, possibly built in to the same plugin), it would recognize the keywords in the special format, and know which fields to write things back into in the original file. This would be a separate step in development.

Does anybody know this to be impossible or severely difficult?  Is there a better approach?

And, does anybody know off-hand what the event triggers relevant to this are?  (See my post today about problems with event tracer; that was my initial idea about how to find them, but it doesn't seem to work with the current version of piwigo.)

Probably not relevant to this question, but since it's easy and formally required, here are the software versions:

Piwigo 2.10.2
Operating system: Linux
PHP: 7.2.30 (Show info) [2020-09-17 13:04:23]
MySQL: 5.7.29-log [2020-09-17 13:04:23]
Graphics Library: ImageMagick 6.9.7-4
(Dreamhost shared-server account, if that matters)

Offline

 

#2 2020-09-18 00:36:22

dd-b
Member
2018-04-16
60

Re: Intentions for new plugin -- importing various metadata as keywords

Looking through tools/triggers_list.php, I can't help noticing that there are no triggers whose names include "sync" or "upload" or "import". Is this a bad sign? There are triggers around metadata, but it appears to be around displaying it directly out of the file, not the initial import.

Is this a bad sign? Am I going to have to be adding triggers? Is that even a thing I can consider?

Offline

 

#3 2020-09-18 02:18:28

jnashpiwigo
Piwigo Team
2014-10-21
246

Re: Intentions for new plugin -- importing various metadata as keywords

*following curiously*

Offline

 

#4 2020-09-18 05:01:03

executive
Member
2017-08-16
1099

Re: Intentions for new plugin -- importing various metadata as keywords

yes there are sync triggers. Look at existing plugins.

Offline

 

#5 2020-09-18 06:11:31

ddtddt
Piwigo Team
Quetigny - France
2007-07-27
6999

Re: Intentions for new plugin -- importing various metadata as keywords

Hi :-)

have you test

$conf['use_exif_mapping'] = array(
....
);


You love Piwigo so don't hesitate to participate, learn more on the "Contribute to Piwigo" page. If you don't have much time for contribution, you can also help the project with a donation.

Offline

 

#6 2020-09-18 07:04:12

dd-b
Member
2018-04-16
60

Re: Intentions for new plugin -- importing various metadata as keywords

Huh; how *does* that config stuff interact with a plugin, anyway? 

I think I need to go back and make sure the config is properly bringing in ordinary keywords in the first place; it used to, but some simple tests seem to suggest it isn't right now.  We'll see where that leads me!

Offline

 

#7 2020-09-18 13:21:04

eliz82
Member
Romania
2016-04-27
280

Re: Intentions for new plugin -- importing various metadata as keywords

dd-b wrote:

Huh; how *does* that config stuff interact with a plugin, anyway? 

I think I need to go back and make sure the config is properly bringing in ordinary keywords in the first place; it used to, but some simple tests seem to suggest it isn't right now.  We'll see where that leads me!

you probably need to call the global before use it

Code:

add_event_handler('some_trigger_event', 'do_something');

function do_something() {
   //example how to get config data
   global $conf;
   if (isset($conf['example'])) {
     $my_var = $conf['example'];
     return $my_var;
  }
  return false
}

just learn to code an extension by studding the code of existing extensions, start with this one
https://piwigo.org/ext/extension_view.php?eid=543

then learn triggers:
https://piwigo.org/demo/tools/triggers_list.php

Last edited by eliz82 (2020-09-18 13:23:27)

Offline

 
  •  » Extensions
  •  » Intentions for new plugin -- importing various metadata as keywords

Board footer

Powered by FluxBB

github twitter newsletter Donate Piwigo.org © 2002-2021 · Contact