#14981t3lib_BEfunc::thumbCode returns wrong image path if image is displayed directly as thumbnail
Description
If the image is small enough to be it’s own thumbnail, the path for the image is messed up.
The image path is build like: ‘‘
which means you change to the parent directory of the script, then the backpath to typo3-directory, then the image path. which is wrong.
I believe it should look like: ‘‘
first go back to the typo3-directory, then change to parent directory and then the path to the image.
This bug only affects localy installed modules.
For example:
If TemplaVoila is installed global, the module path is ‘typo3/ext/templavoila/mod1’ and the backPath is ‘../../../’ then the image path is ‘../../../../uploads/pics/image.gif’. This is a valid path and the image is displayed.
But if TemplaVoila is installed localy, the module path is ‘typo3conf/ext/templavoila/mod1/’ and the backPath is ‘../../../../typo3’. So if the backPath is PREPENDED with ‘../’ the image path would look something like ‘../../../../../typo3/uploads/pics/image.gif’, but this isn’t a valid path to the image. So no thumbnail is displayed.
If the backpath would be APPENDED by ‘../’ the image path would look like ‘../../../../typo3/../uploads/pics/image.gif’. This would be a valid path.
The methods original code:
01: function thumbCode($row,$table,$field,$backPath,$thumbScript=’‘,$uploaddir=NULL,$abs=0,$tparams=’‘,$size=’‘) {
02: global $TCA;
03: // Load table.
04: t3lib_div::loadTCA($table);
05:
06: // Find uploaddir automatically
07: $uploaddir = (is_null($uploaddir)) ? $TCA[$table][‘columns’][$field][‘config’][‘uploadfolder’] : $uploaddir;
08: $uploaddir = preg_replace(‘#/$#’,’‘,$uploaddir);
09:
10: // Set thumbs-script:
11: if (!$GLOBALS[‘TYPO3_CONF_VARS’][‘GFX’][‘thumbnails’]) {
12: $thumbScript=‘gfx/notfound_thumb.gif’;
13: } elseif(!$thumbScript) {
14: $thumbScript=‘thumbs.php’;
15: }
16: // Check and parse the size parameter
17: $sizeParts=array();
18: if ($size = trim($size)) {
19: $sizeParts = explode(‘x’, $size.‘x’.$size);
20: if(!intval($sizeParts0)) $size=’‘;
21: }
22:
23: // Traverse files:
24: $thumbs = explode(‘,’, $row[$field]);
25: $thumbData=’‘;
26: while(list(,$theFile)=each($thumbs)) {
27: if (trim($theFile)) {
28: $fI = t3lib_div::split_fileref($theFile);
29: $ext = $fI[‘fileext’];
30: // New 190201 start
31: $max=0;
32: if (t3lib_div::inList(‘gif,jpg,png’,$ext)) {
33: $imgInfo=@getimagesize(PATH_site.$uploaddir.’/’.$theFile);
34: if (is_array($imgInfo)) {$max = max($imgInfo0,$imgInfo1);}
35: }
36: // use the original image if it’s size fits to the thumbnail size
37: if ($max && $max<=(count($sizeParts)&&max($sizeParts)?max($sizeParts):56)) {
38: $url = $uploaddir.’/’.trim($theFile);
39: $theFile = ‘../’.$url;
40: $onClick=‘top.launchView(\’‘.$theFile.’\’,\’\’,\’‘.$backPath.’\’);return false;’;
41: $thumbData.=’3.’ hspace=“2” border=“0” title=”’.trim($url).’”’.$tparams.’ alt=”“ /> ‘;
42: // New 190201 stop
43: } elseif ($ext==‘ttf’ || t3lib_div::inList($GLOBALS[‘TYPO3_CONF_VARS’][‘GFX’][‘imagefile_ext’],$ext)) {
44: $theFile = ($abs?’‘:’../’).($uploaddir?$uploaddir.’/’:’‘).trim($theFile);
45: $params = ‘&file=’.rawurlencode($theFile);
46: $params .= $size?’&size=’.$size:’‘;
47: $url = $thumbScript.’?&dummy=’.$GLOBALS[‘EXEC_TIME’].$params;
48: $onClick=‘top.launchView(\’‘.$theFile.’\’,\’\’,\’‘.$backPath.’\’);return false;’;
49: $thumbData.=’'.htmlspecialchars($backPath.$url).' ‘;
50: } else {
51: $icon = t3lib_BEfunc::getFileIcon($ext);
52: $url = ‘gfx/fileicons/’.$icon;
53: $thumbData.=’'.$backPath.$url.' ‘;
54: }
55: }
56: }
57: return $thumbData;
58: }
Line number 41 should be changed to:
41: $thumbData.=’3.’ hspace=“2” border=“0” title=”’.trim($url).’”’.$tparams.’ alt=”“ /> ‘;
(issue imported from #M1468)
Reviews 0
No change resolves or names this issue in its commit message, and no comment links one.