From d05ab28549327ac6e3e3e73599bd8330e4dc54d1 Mon Sep 17 00:00:00 2001 From: Terranom674 Date: Wed, 19 Aug 2026 21:26:19 +0200 Subject: [PATCH 1/7] noop --- _noop | 1 + 1 file changed, 1 insertion(+) create mode 100644 _noop diff --git a/_noop b/_noop new file mode 100644 index 0000000..a8b6c94 --- /dev/null +++ b/_noop @@ -0,0 +1 @@ +noop \ No newline at end of file From 7746d26c9ffc8e2fcd452011e34e2971f8cff360 Mon Sep 17 00:00:00 2001 From: Terranom674 Date: Wed, 19 Aug 2026 21:26:47 +0200 Subject: [PATCH 2/7] Remove accidental temporary file --- _noop | 1 - 1 file changed, 1 deletion(-) delete mode 100644 _noop diff --git a/_noop b/_noop deleted file mode 100644 index a8b6c94..0000000 --- a/_noop +++ /dev/null @@ -1 +0,0 @@ -noop \ No newline at end of file From 17c79ce8ab9f2f4f1c75c1434b67ebc77be711f2 Mon Sep 17 00:00:00 2001 From: Terranom674 Date: Wed, 19 Aug 2026 21:27:03 +0200 Subject: [PATCH 3/7] Restore branch to 0.9.7.4 baseline From 5c217288a8a31a83d1c147d033fb3b972a00c9ed Mon Sep 17 00:00:00 2001 From: Terranom674 Date: Wed, 19 Aug 2026 21:27:17 +0200 Subject: [PATCH 4/7] Bump version to 0.9.7.5 --- main.inc.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/main.inc.php b/main.inc.php index efa8988..a2e9db9 100644 --- a/main.inc.php +++ b/main.inc.php @@ -1,7 +1,7 @@ Date: Wed, 19 Aug 2026 21:28:29 +0200 Subject: [PATCH 5/7] Add fast WebDAV gallery derivative path --- include/webdav_gallery_runtime.inc.php | 36 ++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 include/webdav_gallery_runtime.inc.php diff --git a/include/webdav_gallery_runtime.inc.php b/include/webdav_gallery_runtime.inc.php new file mode 100644 index 0000000..495de50 --- /dev/null +++ b/include/webdav_gallery_runtime.inc.php @@ -0,0 +1,36 @@ +id) || empty($src_image->rel_path)) return $url; + + $source_path = str_replace('\\', '/', (string)$src_image->rel_path); + if (!preg_match('#/nc-webdav-source/connection-[0-9]+/root-[0-9]+/.+$#', $source_path)) + { + return $url; + } + + try + { + $derivative = new DerivativeImage($params, $src_image); + if (!$derivative->same_as_source()) + { + $path = $derivative->get_path(); + if ($path !== '' && is_file($path) && is_readable($path)) + { + return $url; + } + } + } + catch (Throwable $e) + { + error_log('Bratonien WebDAV gallery derivative lookup #'.(int)$src_image->id.': '.$e->getMessage()); + } + + $preview_url = bratonien_tools_webdav_image_url((int)$src_image->id, true); + return $preview_url ?: $url; +} From c61d8e32ccff19f3362c3797d138c53b6e65b5b5 Mon Sep 17 00:00:00 2001 From: Terranom674 Date: Wed, 19 Aug 2026 21:28:47 +0200 Subject: [PATCH 6/7] Use fast WebDAV gallery derivative filter --- main.inc.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/main.inc.php b/main.inc.php index a2e9db9..d5772d0 100644 --- a/main.inc.php +++ b/main.inc.php @@ -17,6 +17,7 @@ define('BRATONIEN_TOOLS_PATH', PHPWG_PLUGINS_PATH . BRATONIEN_TOOLS_ID . '/'); require_once(BRATONIEN_TOOLS_PATH . 'include/watermark_runtime.inc.php'); require_once(BRATONIEN_TOOLS_PATH . 'include/webdav_image_runtime.inc.php'); +require_once(BRATONIEN_TOOLS_PATH . 'include/webdav_gallery_runtime.inc.php'); require_once(BRATONIEN_TOOLS_PATH . 'include/public_selection.inc.php'); require_once(BRATONIEN_TOOLS_PATH . 'include/picture_navigation.inc.php'); require_once(BRATONIEN_TOOLS_PATH . 'include/batch_titles.inc.php'); @@ -29,7 +30,7 @@ require_once(BRATONIEN_TOOLS_PATH . 'include/nc_connector_scheduler.inc.php'); add_event_handler('get_admin_plugin_menu_links', 'bratonien_tools_admin_menu'); add_event_handler('get_derivative_url', 'bratonien_tools_filter_derivative_url', EVENT_HANDLER_PRIORITY_NEUTRAL, 4); add_event_handler('get_src_image_url', 'bratonien_tools_filter_webdav_src_url', EVENT_HANDLER_PRIORITY_NEUTRAL + 50, 2); -add_event_handler('get_derivative_url', 'bratonien_tools_filter_webdav_derivative_url', EVENT_HANDLER_PRIORITY_NEUTRAL + 50, 4); +add_event_handler('get_derivative_url', 'bratonien_tools_filter_webdav_gallery_derivative_url', EVENT_HANDLER_PRIORITY_NEUTRAL + 50, 4); add_event_handler('loc_end_element_set_global', 'bratonien_tools_batch_titles_register_action'); add_event_handler('element_set_global_action', 'bratonien_tools_batch_titles_apply', EVENT_HANDLER_PRIORITY_NEUTRAL, 2); add_event_handler('init', 'bratonien_tools_prepare_connector_private_import', EVENT_HANDLER_PRIORITY_NEUTRAL - 30); From ff5af83e659aacbebf245cfe78dbefa4e0de637b Mon Sep 17 00:00:00 2001 From: Terranom674 Date: Wed, 19 Aug 2026 21:29:31 +0200 Subject: [PATCH 7/7] Rebuild only mismatched legacy gallery derivatives --- runtime/lib/build-webdav-derivatives.php | 30 ++++++++++++++++++++---- 1 file changed, 26 insertions(+), 4 deletions(-) diff --git a/runtime/lib/build-webdav-derivatives.php b/runtime/lib/build-webdav-derivatives.php index 2ba24d6..b937e09 100644 --- a/runtime/lib/build-webdav-derivatives.php +++ b/runtime/lib/build-webdav-derivatives.php @@ -6,7 +6,7 @@ if (PHP_SAPI !== 'cli') exit(1); } -const BRATONIEN_WEBDAV_DERIVATIVE_BUILDER_VERSION = '0.9.7.4'; +const BRATONIEN_WEBDAV_DERIVATIVE_BUILDER_VERSION = '0.9.7.5'; $options = getopt('', array('piwigo-root:', 'connection-id:')); $piwigo_root = rtrim((string)($options['piwigo-root'] ?? ''), '/'); @@ -54,9 +54,6 @@ try throw new RuntimeException('Piwigo-Galeriederivat ist nicht konfiguriert.'); } - // Only the gallery thumbnail is prebuilt. Keep the Piwigo target type/path, - // but never crop to the 1x1 placeholder geometry. The real Nextcloud - // preview dimensions determine the aspect ratio. $gallery_params = clone $standard_gallery; $gallery_params->sizing = new SizingParams( array( @@ -73,6 +70,7 @@ try $generated_or_ready = 0; $identity = 0; $metadata_repaired = 0; + $legacy_derivatives_rebuilt = 0; $errors = 0; $error_lines = array(); @@ -133,6 +131,29 @@ try continue; } + $target = $probe->get_path(); + if ($target !== '' && is_file($target) && is_readable($target)) + { + $expected_size = $gallery_params->compute_final_size(array($preview_width, $preview_height)); + $existing_size = @getimagesize($target); + if ( + is_array($expected_size) + && isset($expected_size[0], $expected_size[1]) + && is_array($existing_size) + && isset($existing_size[0], $existing_size[1]) + && ((int)$existing_size[0] !== (int)$expected_size[0] || (int)$existing_size[1] !== (int)$expected_size[1]) + ) + { + if (!@unlink($target)) + { + $errors++; + $error_lines[] = 'Bild #'.$image_id.' Galerie: falsches Alt-Derivat konnte nicht entfernt werden: '.$target; + continue; + } + $legacy_derivatives_rebuilt++; + } + } + $detail = ''; if (bratonien_tools_webdav_generate_derivative($gallery_params, $src, $detail)) { @@ -175,6 +196,7 @@ try ' bereit='.$generated_or_ready. ' identisch='.$identity. ' metadaten_repariert='.$metadata_repaired. + ' alt_derivate_neu='.$legacy_derivatives_rebuilt. ' fehler='.$errors."\n"; exit($errors > 0 ? 1 : 0);