Project

General

Profile

Actions

Feature #16452

closed

Load $GLOBALS['TSFE'] with image dimensions when IMG_RESOURCE is used (feature request!)

Added by Christopher over 17 years ago. Updated about 17 years ago.

Status:
Closed
Priority:
Should have
Category:
Communication
Target version:
-
Start date:
2006-08-10
Due date:
% Done:

0%

Estimated time:
PHP Version:
4
Tags:
Complexity:
Sprint Focus:

Description

As documented in the TSref, the IMAGE cObject loads $GLOBALS['TSFE']->lastImageInfo with the height, width and url of the image. This would be a very useful addition to the IMG_RESOURCE object as well--especially for dynamically generating CSS--specifically for generating background properties.

At the moment, for example, if we want to generate this:

#something {
width:456px;
height:56px;
background-image:url(typo3temp/GB/fubar.png);
}

...we can easily achieve all we need with TS, except the image dimensions. But these dimensions are ALREADY calculated when the IMG_RESOURCE cObject calls getImgResource(), so it seems foolish to re-calculate them with a userFunc, extension etc.

All that is required is the addition of a single line to the IMG_RESOURCE() function in class.tslib_content.php:

ORIGINAL:

00724 function IMG_RESOURCE($conf) {
00725 $imgArray = $this->getImgResource($conf['file'],$conf['file.']);
00726 return $this->stdWrap($imgArray3,$conf['stdWrap.']);
00727 }

MODIFIED:

00724 function IMG_RESOURCE($conf) {
00725 $imgArray = $this->getImgResource($conf['file'],$conf['file.']);
NEW LINE: $GLOBALS['TSFE']->lastImgResourceInfo=$imgArray;
00726 return $this->stdWrap($imgArray3,$conf['stdWrap.']);
00727 }

Possible Problems:

The only problem I was able to conceive of as a result of this change would arise only in a highly specific situation in a TS template:

1. An IMAGE object is created
2. An IMG_RESOURCE object is created
3. Some object is created that uses the contents of TSFE:lastImageInfo, expecting to retrieve the dimensions loaded into it by the IMAGE object created in (1).

In this situation, the TS object in 3 would receive an unexpected value; consequently, I suggest--as is shown in the code above--that a new entry be added to $GLOBALS['TSFE'] by IMG_RESOURCE(). Instead of using $GLOBALS['TSFE']->lastImageInfo as in IMAGE, $GLOBALS['TSFE']->lastImgResourceInfo (or similar) should be used instead.
(issue imported from #M4006)


Files

bug_4006.diff (375 Bytes) bug_4006.diff Administrator Admin, 2007-01-02 05:49
Actions #1

Updated by Christopher over 17 years ago

Patch is based on class.tslib_content.php from TYPO3 4.1beta2.

The added line is identical in form to the line found in cImage() in the same file. The name of the index in $GLOBALS is unique as described above.

Actions

Also available in: Atom PDF