[TYPO3] Optimized code for image resizing?
Lasse Guldsborg
lasse at clioonline.dk
Wed Apr 18 14:55:46 CEST 2007
Hi list
I am experiencing some extremely long load times (+60 seconds the first time
an image is used) on my website, and I think it has something to do with the
way I resize images in an extension I have made.
Can anyone point out if I can optimize my code for better load time
performance? Or should I just blame my ISP ;o)
My TS setup is as so:
############# Polaroid Photo ###############
plugin.user_polaroidphoto_pi1 {
displayimageCObject = IMAGE
displayimageCObject.file.width = 276
#displayimageCObject.file.height = 207
}
And my extension PHP is like this:
// Saves initial values of the image, to be used in the "click to enlarge"
pop-up window.
$largepicture = "uploads/tx_userpolaroidphoto/".$indhold["picture"][0];
list($largepicture_width, $largepicture_height) =
getimagesize($largepicture);
// Call to typoscript to resize image
$imgTSConfig = $this->conf['displayimageCObject.'];
$imgTSConfig['file'] =
"uploads/tx_userpolaroidphoto/".$indhold["picture"][0];
// The image returns from TypoScript in the correct size
$picturefile_TS = $this->cObj->IMAGE($imgTSConfig);
// The image returns as a string in the var $picturefile_TS. This string is
now split up in smaller pices.
$ny_streng = explode(" ", $picturefile_TS);
// First element in the new string is the path to the image (src="xxx")
$src = $ny_streng[1];
// " is removed
$ny_src = explode("\"", $src);
// The "pure" path to the image is put into a new var
$picture_path = $ny_src[1];
// Same procedure with the image width.
$width = $ny_streng[2];
$ny_width = explode("\"", $width);
$picture_width = $ny_width[1];
// Same procedure with the image height.
$height = $ny_streng[3];
$ny_height = explode("\"", $height);
$picture_height = $ny_height[1];
Best regards,
Lasse
More information about the TYPO3-english
mailing list