[TYPO3] Image zoom only if width > X

Christopher bedlamhotel at gmail.com
Fri Aug 11 18:23:35 CEST 2006


Hi,

On 8/11/06, JoH <info at cybercraft.de> wrote:
> >> tt_content.image.20.1.imageLinkWrap {
> >>    enable.data = register:IMAGE_NUM
> >>    enable.postUserFunc = yourWidthCheckingFunction
> >> }
> >>
> >> You need the register to get the position of the image in the CSV
> >> list of files.
> >
> > It cannot be done strictly using Typoscript?
>
> AFAIK there is no way to get the size of the original image with TypoScript
> only, but I might be wrong.
>


I just discovered this in the TSref this week [1]:

"The array $GLOBALS["TSFE"]->lastImageInfo is set with the info-array
of the returning image (if any) and contains width, height and so on."

This means you *can* access the properties of an image:

# Any IMAGE cObject:

5 = IMAGE
5 { ... }

# A HTML cObject to report the image's properties:
# 0 = width
# 1 = height
# 2 = ? (haven't tested this and it's not immediately obvious from the code)
# 3 = url (i.e. the value of the 'src' attribute)

10 = HTML
10.value.dataWrap = [ Image width: {TSFE:lastImageInfo|0} ][ Image
height: {TSFE:lastImageInfo|1} ][ Image url: {TSFE:lastImageInfo|3} ]

Unfortunately, it looks as though the properties are only set after
.if is calculated on the image (so you apparently can't change how the
image is rendered based on its own properties):

[From class.tslib_content.php [2]]

00705         function IMAGE($conf)   {
00706                 $content='';
00707                 if ($this->checkIf($conf['if.']))       {
00708                         $theValue = $this->cImage($conf['file'],$conf);
00709                         if ($conf['stdWrap.'])  {
00710                                 $theValue =
$this->stdWrap($theValue,$conf['stdWrap.']);
00711                         }
00712                         return $theValue;
00713                 }
00714         }

The 'if' check happens at 707, and only then is the actual processing
(and loading of TSFE with image properties) done by the function
cImage() [3].

In  case anyone's interested, I've suggested on the bugtracker [4]
that something similar be done for IMG_RESOURCE cObjects.


-Christopher


[1] http://typo3.org/documentation/document-library/references/doc_core_tsref/current/view/8/6/
[2] http://typo3.org/fileadmin/typo3api-4.0.0/d4/d1b/class_8tslib__content_8php-source.html#l00705
[3] http://typo3.org/fileadmin/typo3api-4.0.0/d4/d1b/class_8tslib__content_8php-source.html#l02599
[4] http://bugs.typo3.org/view.php?id=4006



More information about the TYPO3-english mailing list