But ImageMagick has to be installed und in config.php the corresponding path has to be set
create a new file named "checkthumb.php" and put this in "template/config/"for saving my own hacks on updating phpwcms, I put the custom files at the moment in "template/config/". Then I have in most cases just an include statement in one of the core files. And the location of this include could be documented in the custom file.
copy the following code in the new file:
Code: Select all
<?php
/*
edit file: include/inc_tmpl/files.private.editfile.tmpl.php
edit type: insert
edit location: line 159
edit code: include_once(PHPWCMS_ROOT.'/template/config/checkthumb.php');
edit comment: before line containing $ja = 1;
*/
if ($phpwcms['imagick_path'] != '') { // check if ImageMagick is set
$thumbMaxHeight = 80; // set the thumb height instead of using the thumb height in config.php
$currentPath = PHPWCMS_ROOT.'/filearchive/';
$currentFile = $row["f_hash"] . '.' . $row["f_ext"];
if ($row["f_ext"] == 'pdf') { // check if current file is of type pdf
if (!file_exists($currentPath . $row["f_hash"] . '.jpg')) { // check if thumb already exists
// no thumb yet so create one
$im = new imagick($currentPath . $currentFile . '[0]');
$im->setImageFormat('jpg');
$im->thumbnailImage(0,$thumbMaxHeight);
$im->writeImage('filearchive/' . $row["f_hash"] . '.jpg');
$im->clear();
$im->destroy();
}
$file_thumb_small = '<img src="filearchive/' . $row["f_hash"] . '.jpg"/>';
$othumb = true;
}
}
?>
Code: Select all
include_once(PHPWCMS_ROOT.'/template/config/checkthumb.php');
in filecenter when you click the edit button of a uploaded pdf file, the code checks if a thumb exists, if not, it creates one.
later I can now create a custom DOWNLOAD-RT and use this thumb in my pdf downloads.
use it at your own risk. it just fits my own needs.
the result is looking like this (the filename is the same as the pdf - not the real filename - the hash used in phpwcms):