Compare commits

...

6 Commits

Author SHA1 Message Date
Terranom674
ba0b5af417 Release 0.9.7.4 2026-08-19 21:12:39 +02:00
Terranom674
315af9641c Build only gallery derivative from WebDAV preview 2026-08-19 21:12:24 +02:00
Terranom674
77ae007a28 Merge pull request #25 from Terranom674/fix/0973-webdav-root-altimports
0.9.7.3: Altimporte aus WebDAV-Stammverzeichnis reparieren
2026-08-19 21:02:13 +02:00
Terranom674
e5be2b3043 Release 0.9.7.3 2026-08-19 21:01:26 +02:00
Terranom674
3fe9527537 Fix root WebDAV alt-import derivative detection 2026-08-19 21:01:00 +02:00
Terranom674
fb1f12d608 0.9.7.2: sichtbarer Abgleich und sicherer WebDAV-Import
0.9.7.2: sichtbarer Abgleich und sicherer WebDAV-Import
2026-08-19 20:53:28 +02:00
3 changed files with 57 additions and 38 deletions

View File

@@ -49,18 +49,21 @@ function bratonien_tools_webdav_image_source_info($image_id)
}
$root_path = '';
$root_found = false;
$roots = isset($config['roots']) && is_array($config['roots']) ? $config['roots'] : array();
foreach ($roots as $root)
{
if ((int)($root['fileid'] ?? 0) === $root_fileid)
{
$root_path = trim((string)($root['webdav_path'] ?? ''), '/');
$root_found = true;
break;
}
}
if ($root_path === '') return $cache[$image_id] = null;
if (!$root_found) return $cache[$image_id] = null;
$webdav_path = $root_path.'/'.$relative_path;
$root_is_base = $root_path === '';
$webdav_path = $root_is_base ? $relative_path : $root_path.'/'.$relative_path;
$content_type = '';
$size = 0;
$etag = '';
@@ -90,6 +93,7 @@ function bratonien_tools_webdav_image_source_info($image_id)
'image_id'=>$image_id,
'connection_id'=>$connection_id,
'webdav_path'=>$webdav_path,
'root_is_base'=>$root_is_base,
'content_type'=>$content_type,
'size'=>$size,
'etag'=>$etag,
@@ -415,6 +419,8 @@ function bratonien_tools_filter_webdav_derivative_url($url, $params, $src_image,
$info = bratonien_tools_webdav_image_source_info((int)$src_image->id);
if (!$info) return $url;
if (empty($info['root_is_base']))
{
try
{
$derivative = new DerivativeImage($params, $src_image);
@@ -428,6 +434,7 @@ function bratonien_tools_filter_webdav_derivative_url($url, $params, $src_image,
{
error_log('Bratonien WebDAV derivative lookup #'.(int)$src_image->id.': '.$e->getMessage());
}
}
$preview_url = bratonien_tools_webdav_image_url((int)$src_image->id, true);
return $preview_url ?: $url;

View File

@@ -1,7 +1,7 @@
<?php
/*
Plugin Name: Bratonien Tools
Version: 0.9.7.2
Version: 0.9.7.4
Description: Erweiterbare Administrationswerkzeuge fuer die Bratonien-Piwigo-Installation.
Plugin URI: https://github.com/Terranom674/Piwigo_Bratonien_Tools
Author: Bratonien

View File

@@ -6,7 +6,7 @@ if (PHP_SAPI !== 'cli')
exit(1);
}
const BRATONIEN_WEBDAV_DERIVATIVE_BUILDER_VERSION = '0.9.6.1';
const BRATONIEN_WEBDAV_DERIVATIVE_BUILDER_VERSION = '0.9.7.4';
$options = getopt('', array('piwigo-root:', 'connection-id:'));
$piwigo_root = rtrim((string)($options['piwigo-root'] ?? ''), '/');
@@ -48,12 +48,27 @@ if (!function_exists('bratonien_tools_webdav_image_source_info') || !function_ex
try
{
$variants = bratonien_tools_webdav_derivative_variants();
if (!$variants)
$standard_gallery = ImageStdParams::get_by_type(IMG_THUMB);
if (!$standard_gallery || !isset($standard_gallery->sizing->ideal_size))
{
throw new RuntimeException('Keine Piwigo-Derivate konfiguriert.');
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(
(int)$standard_gallery->sizing->ideal_size[0],
(int)$standard_gallery->sizing->ideal_size[1],
),
0,
null
);
$gallery_params->type = IMG_THUMB;
$gallery_params->use_watermark = false;
$images = 0;
$generated_or_ready = 0;
$identity = 0;
@@ -109,11 +124,9 @@ try
}
$src = new SrcImage($row);
foreach ($variants as $variant_name => $params)
{
try
{
$probe = new DerivativeImage($params, $src);
$probe = new DerivativeImage($gallery_params, $src);
if ($probe->same_as_source())
{
$identity++;
@@ -121,21 +134,20 @@ try
}
$detail = '';
if (bratonien_tools_webdav_generate_derivative($params, $src, $detail))
if (bratonien_tools_webdav_generate_derivative($gallery_params, $src, $detail))
{
$generated_or_ready++;
}
else
{
$errors++;
$error_lines[] = 'Bild #'.$image_id.' '.$variant_name.': '.($detail !== '' ? $detail : 'Derivat konnte nicht erzeugt werden.');
$error_lines[] = 'Bild #'.$image_id.' Galerie: '.($detail !== '' ? $detail : 'Galeriederivat konnte nicht erzeugt werden.');
}
}
catch (Throwable $e)
{
$errors++;
$error_lines[] = 'Bild #'.$image_id.' '.$variant_name.': '.get_class($e).': '.$e->getMessage();
}
$error_lines[] = 'Bild #'.$image_id.' Galerie: '.get_class($e).': '.$e->getMessage();
}
}
@@ -159,7 +171,7 @@ try
echo 'WebDAV-Derivative-Builder: version='.BRATONIEN_WEBDAV_DERIVATIVE_BUILDER_VERSION.
' bilder='.$images.
' varianten='.count($variants).
' varianten=1'.
' bereit='.$generated_or_ready.
' identisch='.$identity.
' metadaten_repariert='.$metadata_repaired.