Corrected image link generation for image preview.

This fixes broken preview images if media ids are used in the file pattern
(parameter 'direct=0'). Fixes #27.
This commit is contained in:
LarsDW223
2018-04-07 12:55:36 +02:00
parent ed94025e20
commit bfd71e37a5

View File

@@ -533,9 +533,15 @@ class syntax_plugin_filelist extends DokuWiki_Syntax_Plugin {
* @return void
*/
protected function _render_preview_image ($filepath, $basedir, $webdir, $params, Doku_Renderer $renderer) {
$imagepath = $this->get_preview_image_path($filepath, $params);
$imagepath = $this->get_preview_image_path($filepath, $params, $isImage);
if (!empty($imagepath)) {
$imgLink = $this->_get_link_url ($imagepath, $basedir, $webdir, 0, 1);
if ($isImage == false) {
// Generate link to returned filetype icon
$imgLink = $this->_get_link_url ($imagepath, $basedir, $webdir, 0, 1);
} else {
// Generate link to image file
$imgLink = $this->_get_link_url ($filepath, $basedir, $webdir, $params['randlinks'], $params['direct'], $params['ftp']);
}
$previewsize = $params['previewsize'];
if ($previewsize == 0) {
@@ -989,13 +995,15 @@ class syntax_plugin_filelist extends DokuWiki_Syntax_Plugin {
* @param $filename the file to check
* @return string Image to use for preview image
*/
protected function get_preview_image_path ($filename, $params) {
protected function get_preview_image_path ($filename, $params, &$isImage) {
list($ext,$mime) = mimetype(basename($filename));
$imagepath = '';
$isImage = false;
if (($params['preview'] == 1 || $params['preview'] == 2) &&
strncmp($mime, 'image', strlen('image')) == 0) {
// The file is an image. Return itself as the image path.
$imagepath = $filename;
$isImage = true;
}
if (($params['preview'] == 1 && empty($imagepath)) ||
$params['preview'] == 3 ) {