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.
You are right. This saves me about 30 lines of code.
I haven't found any code to insert the EXIF timestamp for files that will be added after plugin installation.
My hook into CPGPluginAPI::action('add_file_data_success', $CURRENT_PIC_DATA) got lost somehow. Now it is in again.
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.
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?
Maybe a separate button to update (missing) EXIF timestamps will to the trick.
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...