Skip to content

Commit

Permalink
[BUGFIX] Render file preview in result list only for files in "imagef…
Browse files Browse the repository at this point in the history
…ile_ext", closes #60
  • Loading branch information
christianbltr committed Apr 26, 2024
1 parent 50df44d commit 30cbcde
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
1 change: 1 addition & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ ChangeLog
Upcoming version
[FEATURE] Add pagination in the backend module "Indexed content" function and avoid out of memory error. https://github.com/tpwd/ke_search/issues/100
[TASK] Add BEGIN and COMMIT statements needed to run ke_search in a Percona-Database-Cluster with strict-mode. Thanks to rentz-skygate. https://github.com/tpwd/ke_search/issues/222
[BUGFIX] Render file preview in result list only for files which are in the "imagefile_ext" list (images and PDF files). https://github.com/tpwd/ke_search/issues/60

Version 5.4.1, 19 April 2024
[BUGFIX] Always remove duplicates from tags, not only when a tag is set in the indexer configuration. https://github.com/tpwd/ke_search/issues/211
Expand Down
17 changes: 16 additions & 1 deletion Classes/Plugins/PluginBase.php
Original file line number Diff line number Diff line change
Expand Up @@ -786,19 +786,34 @@ public function getSearchResults()
// for files we have the corresponding entry in sys_file as "orig_uid" available (not sys_file_reference)
// for pages and news we have to fetch the file reference uid
if ($type == 'file') {
$fileExtension = '';
if ($this->conf['showFilePreview'] ?? '') {
// SearchHelper::getFile will return af FILE object if it is a FAL file,
// otherwise it's a plain path to a file
if (SearchHelper::getFile($row['orig_uid'])) {
$file = SearchHelper::getFile($row['orig_uid']);
if ($file) {
// FAL file
$resultrowTemplateValues['filePreviewId'] = $row['orig_uid'];
$fileExtension = $file->getExtension();
} else {
// no FAL file or FAL file does not exist
if (file_exists($row['directory'] . $row['title'])) {
$resultrowTemplateValues['filePreviewId'] = $row['directory'] . $row['title'];
$fileExtension = pathinfo($row['title'], PATHINFO_EXTENSION);
}
}
}
$filePreviewPossible = in_array(
$fileExtension,
GeneralUtility::trimExplode(
',',
$GLOBALS['TYPO3_CONF_VARS']['GFX']['imagefile_ext'],
true
)
);
if (!$filePreviewPossible) {
$resultrowTemplateValues['filePreviewId'] = 0;
}
$resultrowTemplateValues['treatIdAsReference'] = 0;
} else {
$resultrowTemplateValues['filePreviewId'] = $this->getFileReference($row);
Expand Down

0 comments on commit 30cbcde

Please sign in to comment.