Support > cpg1.6 plugin contributions

Sort by EXIF date

(1/5) > >>

Ludger:
I hope this is the right place, so here we go:
Good evening,
I am new to this forum and have just recently moved my private picture and movie gallery to a Coppermine-based site. I like the software very much with one exception: I painfully missed the option of sorting the album thumbnails by the original date from EXIF data. And since I am used to making the things I miss myself, I started making a new plugin for exactly this purpose. Now this thing is basically done, I am still testing...
To do what it is supposed to do, my plugin depends on 2 CPGPluginAPI-Lines that I added to functions.inc.php. Would it be possible to add these two "plugs" to future releases of Coopermine 1.5 and 1.6? My plugin works with these two versions.
Best regards from Aachen, Germany
Ludger
PS: I have opend a smal part of my site on http://bergdriesch22.de . The universal registration password is himbeereis123 .

Ludger:
...these are the modified functions.inc.php . In the 1.5 version I added lines 1367 and 2155, in 1.6 I added the same lines at 1415 and 2177.
PS: I updated the patching according to what Ron did (see below).

Αndré:
Some remarks. The check for $main_version is probably not needed, if you use the database wrapper functions, e.g. cpg_db_num_rows instead of mysql_num_rows.

I haven't found any code to insert the EXIF timestamp for files that will be added after plugin installation.

It seems you insert all EXIF timestamps during plugin installation. This will probably fail on large galleries with a comparatively small timeout value. You should better do this in a loop and add just (let's say) 100 items a time, like we do in the admin tools. Maybe a separate button to update (missing) EXIF timestamps will to the trick.

The plugin hooks themselves looks valid.

Ludger:

--- Quote from: Αndré on December 15, 2017, 12:16:17 pm ---The check for $main_version is probably not needed, if you use the database wrapper functions, e.g. cpg_db_num_rows instead of mysql_num_rows.
--- End quote ---
You are right. This saves me about 30 lines of code.


--- Quote ---I haven't found any code to insert the EXIF timestamp for files that will be added after plugin installation.
--- End quote ---
My hook into CPGPluginAPI::action('add_file_data_success', $CURRENT_PIC_DATA) got lost somehow. Now it is in again.


--- Quote ---It seems you insert all EXIF timestamps during plugin installation. This will probably fail on large galleries with a comparatively small timeout value. You should better do this in a loop and add just (let's say) 100 items a time, like we do in the admin tools.
--- End quote ---
The updates already take place in a loop as one query execution per loop. Here is the loop:

   while ($picture = single_picture($result2)) {
      $result = load_exif($picture);   
   };

And here is the function called:

function load_exif($picture) {
   global $CONFIG;
   $exifdata = exif_read_data($CONFIG['fullpath'].$picture['filepath'].$picture['filename']);
   if (isset($exifdata['DateTimeOriginal'])) {
         $datum = $exifdata['DateTimeOriginal'];
         $isexif = 1;
      } else {
         $datum = date('Y-m-d H:i:s:', filectime($CONFIG['fullpath'].$picture['filepath'].$picture['filename']));
         $isexif = 0;
      };
   $result = cpg_db_query("update {$CONFIG['TABLE_PICTURES']} set sbe_exif_date='{$datum}', sbe_source_is_exif='{$isexif}' where pid = {$picture['pid']}");
   return $result;
}

Just putting another big loop around my small one does not make sense for me, does it?


--- Quote ---Maybe a separate button to update (missing) EXIF timestamps will to the trick.
--- End quote ---
I think, this is not needed, because EXIF is added after Upload. But still a button to re-EXIF (for example once you have exchanged some pictures) would be useful. I am just wondering about the right place for that button. I attached an updated version of the plugin...

Ludger:
...forgot the link...

Navigation

[0] Message Index

[#] Next page

Go to full version