Add setting for thumbnail scaling
Some checks failed
DokuWiki Default Tasks / all (push) Has been cancelled
Some checks failed
DokuWiki Default Tasks / all (push) Has been cancelled
This commit is contained in:
29
Output.php
29
Output.php
@@ -58,12 +58,27 @@ class Output
|
||||
$thumbH = 150;
|
||||
$thumbQ = 80;
|
||||
|
||||
$placeholderUrl = DOKU_BASE . 'lib/images/blank.gif';
|
||||
// Allow generating larger thumbnails (e.g. 2x) while still displaying them
|
||||
// at 150x150 for sharper results on HiDPI screens.
|
||||
$thumbScale = 1.0;
|
||||
$syntax = plugin_load('syntax', 'luxtools');
|
||||
if ($syntax) {
|
||||
$rawScale = (string)$syntax->getConf('gallery_thumb_scale');
|
||||
if ($rawScale !== '') {
|
||||
$thumbScale = (float)$rawScale;
|
||||
}
|
||||
}
|
||||
if (!is_finite($thumbScale) || $thumbScale < 1.0) $thumbScale = 1.0;
|
||||
if ($thumbScale > 4.0) $thumbScale = 4.0;
|
||||
|
||||
$genThumbW = (int)max(1, (int)round($thumbW * $thumbScale));
|
||||
$genThumbH = (int)max(1, (int)round($thumbH * $thumbScale));
|
||||
|
||||
$placeholderUrl = DOKU_BASE . 'lib/images/blank.gif';
|
||||
$placeholderId = $syntax ? trim((string)$syntax->getConf('thumb_placeholder')) : '';
|
||||
if ($placeholderId !== '' && function_exists('ml')) {
|
||||
// ml() builds a fetch.php URL for a MediaManager item
|
||||
$placeholderUrl = ml($placeholderId, ['w' => $thumbW, 'h' => $thumbH], true, '&');
|
||||
$placeholderUrl = ml($placeholderId, ['w' => $genThumbW, 'h' => $genThumbH], true, '&');
|
||||
}
|
||||
|
||||
/** @var \Doku_Renderer_xhtml $renderer */
|
||||
@@ -74,8 +89,10 @@ class Output
|
||||
$url = $this->itemWebUrl($item, !empty($params['randlinks']));
|
||||
$thumbUrl = $this->withQueryParams($url, [
|
||||
'thumb' => 1,
|
||||
'w' => $thumbW,
|
||||
'h' => $thumbH,
|
||||
'w' => $genThumbW,
|
||||
'h' => $genThumbH,
|
||||
// Keep quality explicit so cache file naming stays stable.
|
||||
'q' => $thumbQ,
|
||||
]);
|
||||
$safeUrl = hsc($url);
|
||||
$safeThumbUrl = hsc($thumbUrl);
|
||||
@@ -83,8 +100,8 @@ class Output
|
||||
$label = hsc($item['name']);
|
||||
|
||||
$initialSrc = $safePlaceholderUrl;
|
||||
$dataThumb = ' data-thumb-src="' . $safeThumbUrl . '"';
|
||||
$thumbCachePath = $this->thumbCachePathForItem($item, $thumbW, $thumbH, $thumbQ);
|
||||
$dataThumb = ' data-thumb-src="' . $safeThumbUrl . '"';
|
||||
$thumbCachePath = $this->thumbCachePathForItem($item, $genThumbW, $genThumbH, $thumbQ);
|
||||
if (is_string($thumbCachePath) && $thumbCachePath !== '' && @is_file($thumbCachePath)) {
|
||||
// Thumb already exists: start with it immediately (no JS swap needed)
|
||||
$initialSrc = $safeThumbUrl;
|
||||
|
||||
@@ -12,6 +12,10 @@ $conf['extensions'] = '';
|
||||
// MediaManager ID for gallery thumbnail placeholder
|
||||
$conf['thumb_placeholder'] = ':wiki:thumb-placeholder.png';
|
||||
|
||||
// Multiplier for gallery thumbnail generation size (1 = 150x150, 2 = 300x300).
|
||||
// Thumbnails are still displayed as 150x150 on the page.
|
||||
$conf['gallery_thumb_scale'] = 1;
|
||||
|
||||
// Local opener service used by {{open>...}}.
|
||||
$conf['open_service_url'] = 'http://127.0.0.1:8765';
|
||||
$conf['open_service_token'] = '';
|
||||
|
||||
@@ -14,5 +14,8 @@ $meta['extensions'] = array('string');
|
||||
|
||||
$meta['thumb_placeholder'] = array('string');
|
||||
|
||||
// Thumbnail generation scale factor for the {{images>...}} gallery.
|
||||
$meta['gallery_thumb_scale'] = array('string');
|
||||
|
||||
$meta['open_service_url'] = array('string');
|
||||
$meta['open_service_token'] = array('string');
|
||||
|
||||
@@ -4,5 +4,7 @@ $lang['allow_in_comments'] = 'Files-Syntax in Kommentaren erlauben.';
|
||||
|
||||
$lang['thumb_placeholder'] = 'MediaManager-ID für den Platzhalter der Galerie-Thumbnails';
|
||||
|
||||
$lang['gallery_thumb_scale'] = 'Skalierungsfaktor für Galerie-Thumbnails. 2 erzeugt schärfere Thumbnails auf HiDPI-Displays (Anzeige bleibt 150×150).';
|
||||
|
||||
$lang['open_service_url'] = 'URL des lokalen Öffner-Dienstes für {{open>...}} (z.B. http://127.0.0.1:8765).';
|
||||
$lang['open_service_token'] = 'Token für den lokalen Öffner-Dienst (X-Filetools-Token).';
|
||||
|
||||
@@ -6,5 +6,7 @@ $lang['extensions'] = 'Comma-separated list of allowed file extensions to list';
|
||||
|
||||
$lang['thumb_placeholder'] = 'MediaManager ID for the gallery thumbnail placeholder';
|
||||
|
||||
$lang['gallery_thumb_scale'] = 'Gallery thumbnail scale factor. Use 2 for sharper thumbnails on HiDPI screens (still displayed as 150×150).';
|
||||
|
||||
$lang['open_service_url'] = 'Local opener service URL for the {{open>...}} button (e.g. http://127.0.0.1:8765).';
|
||||
$lang['open_service_token'] = 'Token sent to the local opener service (X-Filetools-Token).';
|
||||
|
||||
@@ -10,5 +10,7 @@ $lang['extensions'] = 'Komma-gescheiden lijst van toegestane bestandsextensies v
|
||||
|
||||
$lang['thumb_placeholder'] = 'MediaManager-ID voor de placeholder van galerij thumbnails';
|
||||
|
||||
$lang['gallery_thumb_scale'] = 'Schaalfactor voor galerij thumbnails. Gebruik 2 voor scherpere thumbnails op HiDPI-schermen (weergave blijft 150×150).';
|
||||
|
||||
$lang['open_service_url'] = 'Lokale opener service-URL voor de {{open>...}} knop (bijv. http://127.0.0.1:8765).';
|
||||
$lang['open_service_token'] = 'Token dat naar de lokale opener service wordt gestuurd (X-Filetools-Token).';
|
||||
|
||||
Reference in New Issue
Block a user