Project

General

Profile

Actions

Bug #14981

closed

t3lib_BEfunc::thumbCode returns wrong image path if image is displayed directly as thumbnail

Added by old_posimis almost 19 years ago. Updated over 5 years ago.

Status:
Closed
Priority:
Should have
Assignee:
Category:
-
Target version:
-
Start date:
2005-09-20
Due date:
% Done:

0%

Estimated time:
TYPO3 Version:
3.8.0
PHP Version:
4
Tags:
Complexity:
Is Regression:
Sprint Focus:

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: '<img src="../'.$backPath.$url.'" />'
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: '<img src="'.$backPath.'../'.$url.'" />'
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.='<a href="#" onclick="'.htmlspecialchars($onClick).'"><img src="../'.$backPath.$url.'" '.$imgInfo3.' hspace="2" border="0" title="'.trim($url).'"'.$tparams.' alt="" /></a> ';
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.='<a href="#" onclick="'.htmlspecialchars($onClick).'"><img src="'.htmlspecialchars($backPath.$url).'" hspace="2" border="0" title="'.trim($theFile).'"'.$tparams.' alt="" /></a> ';
50: } else {
51: $icon = t3lib_BEfunc::getFileIcon($ext);
52: $url = 'gfx/fileicons/'.$icon;
53: $thumbData.='<img src="'.$backPath.$url.'" hspace="2" border="0" title="'.trim($theFile).'"'.$tparams.' alt="" /> ';
54: }
55: }
56: }
57: return $thumbData;
58: }

Line number 41 should be changed to:
41: $thumbData.='<a href="#" onclick="'.htmlspecialchars($onClick).'"><img src="'.$backPath.'../'.$url.'" '.$imgInfo3.' hspace="2" border="0" title="'.trim($url).'"'.$tparams.' alt="" /></a> ';

(issue imported from #M1468)

Actions #1

Updated by Benni Mack about 16 years ago

Hey old_posims...
I see that the change is maybe necessary, but the back_path includes the / already AFAIK. So there is no need to change it.

If we would add this and the backpath would be empty, then the files wouldn't be relative to TYPO3 but relative to the base directory of the webserver. This is IMHO nonsense and so this change is not required in my mind.

Actions #2

Updated by Benni Mack over 5 years ago

  • Status changed from Resolved to Closed
Actions

Also available in: Atom PDF