•  » Requests
  •  » Can the search feature use "Manage Properties Photos" fields?

#1 2023-07-13 10:23:17

BobbyV
Member
Wales
2007-04-22
73

Can the search feature use "Manage Properties Photos" fields?

The "Manage Properties Photos" plugin is perfect for adding custom fields to photos but unless they are included in the "search" facility there is little benefit from adding these fields except for display on the photo page.

I would like to request a new or modified plugin to enable searching for photos with matching custom fields and to create a temporary virtual album based on the results.

For example, I may add a "properties photo" field called "registration number" and then have the ability to search through the entire album collection looking for cars with a registration number = 123XYZ. The results would then be displayed as a temporary album showing any photos of that car.

Would anyone else find this useful or have any suggestions for improvement?

Offline

 

#2 2024-04-21 22:30:44

willem
Member
The Netherlands
2022-04-25
21

Re: Can the search feature use "Manage Properties Photos" fields?

Please add my vote for this request. It looks like the new search in Piwigo 14 has not yet opened this option.

In our case it is about ships with 5 digit registration numbers. We're currently adding them as tags, but this has 2 major drawbacks:

1. The number of tags grows enormously
2. 5-digit numbers can also be part of a date, filename etc. This is confusing to the volunteers working on tagging the collection. So we had to ad extra characters to them to make them unique.

IMHO this will enhance Piwigo's usability as an image library for organisations.

Offline

 

#3 2025-12-25 17:03:48

BobbyV
Member
Wales
2007-04-22
73

Re: Can the search feature use "Manage Properties Photos" fields?

willem wrote:

In our case it is about ships with 5 digit registration numbers.

How many fields would you find useful for each registered ship?

I have been thinking of a new plug-in that would be extremely useful for people who photograph collections of things, such as trains, ships, planes, and cars, where you don't want to have to repeatedly enter (and store) the same information whenever you come across the same train, ship,later.

I suggest a new table with some relevant fields for that object, for example, if cars:
    Registration number (Primary key)
    Manufacturer
    Model
    First registered
etc

My problem is that whilst I can create a table, I have no idea how to do the rest. I have tried to learn how to write plug-ins, but my 73-year-old brain can't cope!

Offline

 

#4 2025-12-25 17:52:34

willem
Member
The Netherlands
2022-04-25
21

Re: Can the search feature use "Manage Properties Photos" fields?

@BobbyV I'm not involved with that ships photobase project anymore, but I think in many other situations custom fields will only be useful if they can be searched.

I'm not a developer (and my brain is not much younger) but I work with WordPress a lot. Like Piwigo, WordPress is a PHP/MySQL application. In WordPress custom fields can be added to all post types and taxonomies, but the default WordPress search only looks at title and post content. However there are several plugins that extend the search functionality and it also seems to be possible by adding a few lines of code in a code-snippet plugin or child-theme. See the 2nd answer in this topic for example.

So it looks like in WordPress the solution is to (slightly) extend the search function rather than adding tables.

Offline

 

#5 2025-12-26 11:10:06

BobbyV
Member
Wales
2007-04-22
73

Re: Can the search feature use "Manage Properties Photos" fields?

willem wrote:

See the 2nd answer in this topic for example.

Many thanks, I'll take a look shortly.

I'm happy to work with anyone that wants to have a go at writing a plug-in for this, maybe someone who writes plug-ins for fun :-)

Offline

 

#6 2025-12-27 21:39:13

moberley
Member
2025-11-10
90

Re: Can the search feature use "Manage Properties Photos" fields?

I have been able lookup images using data in a Manage Properties Photos added property (non-date) using the Piwigo search page through a bit of Personal Plugin code. Unfortunately, the method I used is not intuitive from a user perspective as it uses the expert mode filter instead of the "search for words" input.

I also added a FULLTEXT index to the ADD_PROP_PHOTO_DATA_TABLE 'data' column as I was reusing some existing code in include/functions_search.inc.php but there is probably a different way to generate the query so as not to require changing the database schema of another plugin's table.

I think there might also be another approach that would work as there are some other triggers available in include/functions_search.inc.php that I don't currently understand how to use.

Code:

add_event_handler('qsearch_get_scopes', 'personal_extend_search_scopes');
function personal_extend_search_scopes($scopes)
{
  $scopes[] = new QSearchScope('add_info', array('add_info'));
  return $scopes;
}

add_event_handler('qsearch_before_eval', 'personal_qsearch_get_image_by_add_info_text');
function personal_qsearch_get_image_by_add_info_text(QExpression $expr, QResults $qsr)
{
  for ($i=0; $i<count($expr->stokens); $i++)
  {
    $token = $expr->stokens[$i];
    if (isset($token->scope) && 'add_info' != $token->scope->id)
      continue;
    if (empty($token->term))
      continue;

    $clauses = qsearch_get_text_token_search_sql( $token, array('data'));
    $query = 'SELECT id_img FROM '.ADD_PROP_PHOTO_DATA_TABLE.' WHERE ('. implode("\n OR ",$clauses) .');';
    $result = query2array($query, null, 'id_img');  
    $query = 'SELECT id from '.IMAGES_TABLE.' i WHERE id IN ('. implode(",",$result) .');';
    $qsr->images_iids[$i] = query2array($query,null,'id');
  }
}

Offline

 

#7 2025-12-27 23:56:16

BobbyV
Member
Wales
2007-04-22
73

Re: Can the search feature use "Manage Properties Photos" fields?

moberley wrote:

I have been able lookup images using data in a Manage Properties Photos

Wow, that's a coincidence because earlier today I read up about "Manage Properties Photos" and thought it might be the way to go. However, I encountered an error when attempting to activate it. I've posted the error text in another post, and maybe someone will point me in the right direction.

Your code is beyond me at the moment but I shall read up about triggers tomorrow and see if it makes sense. Thank you very much for your input; every bit helps.

Offline

 

#8 2025-12-28 03:40:20

moberley
Member
2025-11-10
90

Re: Can the search feature use "Manage Properties Photos" fields?

The triggers I am referring to are points (using the functions trigger_notify and trigger_change) in the Piwigo code that allow some other code to do something at that point by registering an event handler, for example a plugin or the LocalFiles Editor Personal Plugin (like what I posted).

Mostly the built-in search is applying queries against columns in the core images table but it can also search tags and albums. However a custom property added by the Manage Properties Photos plugin is stored in its own separate table with a reference to the image ID from the core images table.

The available core triggers are listed at /tools/triggers_list.php on a Piwigo instance (for example https://demo1.piwigo.com/tools/triggers_list.php) but there do seem to be some in /include/functions_search.inc.php that are not on that page. Maybe that means they are not supposed to be used in plugins but the code comments don't seem to indicate that so I'm not sure. I was able to make them work on my Piwigo 16 instance in any case.

I read through the core Piwigo include/functions_search.inc.php file looking for trigger_notify and trigger_change function calls that appeared to be intended to allow plugins to insert into the search process. Then I tried to figure out how to use them to insert image IDs returned from searching in the piwigo_add_properties_photos_data table into the results.

I have a use case where I would like to store a catalog reference from another system along with images in a Piwigo gallery and be able to lookup images using that information so that is why I am looking at how to connect the search tools with the Manage Properties Photos plugin.

Offline

 
  •  » Requests
  •  » Can the search feature use "Manage Properties Photos" fields?

Board footer

Powered by FluxBB

github linkedin newsletter Piwigo.org © 2002-2026 · Contact