V1
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
|
||||
use dokuwiki\Extension\SyntaxPlugin;
|
||||
use dokuwiki\plugin\luxtools\Path;
|
||||
use dokuwiki\plugin\luxtools\PageLink;
|
||||
use dokuwiki\plugin\luxtools\ThumbnailHelper;
|
||||
|
||||
require_once(__DIR__ . '/../autoload.php');
|
||||
@@ -132,7 +133,7 @@ class syntax_plugin_luxtools_image extends SyntaxPlugin
|
||||
}
|
||||
|
||||
try {
|
||||
$pathHelper = new Path($this->getConf('paths'));
|
||||
$pathHelper = new Path($this->buildPathConfigWithBlobs());
|
||||
// Use addTrailingSlash=false since this is a file path, not a directory
|
||||
$pathInfo = $pathHelper->getPathInfo($data['path'], false);
|
||||
} catch (\Exception $e) {
|
||||
@@ -214,6 +215,60 @@ class syntax_plugin_luxtools_image extends SyntaxPlugin
|
||||
return DOKU_BASE . 'lib/plugins/luxtools/file.php?' . http_build_query($params, '', '&');
|
||||
}
|
||||
|
||||
/**
|
||||
* Build a path configuration string, adding the blobs alias if available.
|
||||
*/
|
||||
protected function buildPathConfigWithBlobs(): string
|
||||
{
|
||||
$pathConfig = (string)$this->getConf('paths');
|
||||
$blobsRoot = $this->resolveBlobsRoot();
|
||||
if ($blobsRoot !== '') {
|
||||
$pathConfig = rtrim($pathConfig) . "\n" . $blobsRoot . "\nA> blobs";
|
||||
}
|
||||
return $pathConfig;
|
||||
}
|
||||
|
||||
/**
|
||||
* Resolve the current page's pagelink folder for the blobs alias.
|
||||
*/
|
||||
protected function resolveBlobsRoot(): string
|
||||
{
|
||||
static $cached = [];
|
||||
|
||||
global $ID;
|
||||
$pageId = is_string($ID) ? $ID : '';
|
||||
if ($pageId === '') return '';
|
||||
|
||||
if (function_exists('cleanID')) {
|
||||
$pageId = (string)cleanID($pageId);
|
||||
}
|
||||
if ($pageId === '') return '';
|
||||
|
||||
if (isset($cached[$pageId])) {
|
||||
return (string)$cached[$pageId];
|
||||
}
|
||||
|
||||
$depth = (int)$this->getConf('pagelink_search_depth');
|
||||
if ($depth < 0) $depth = 0;
|
||||
|
||||
$pageLink = new PageLink((string)$this->getConf('paths'), $depth);
|
||||
$uuid = $pageLink->getPageUuid($pageId);
|
||||
if ($uuid === null) {
|
||||
$cached[$pageId] = '';
|
||||
return '';
|
||||
}
|
||||
|
||||
$linkInfo = $pageLink->resolveUuid($uuid);
|
||||
$folder = $linkInfo['folder'] ?? '';
|
||||
if (!is_string($folder) || $folder === '') {
|
||||
$cached[$pageId] = '';
|
||||
return '';
|
||||
}
|
||||
|
||||
$cached[$pageId] = $folder;
|
||||
return $folder;
|
||||
}
|
||||
|
||||
/**
|
||||
* Render the imagebox HTML.
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user