[xseitenbilder] Code suggestion for better image support
I noticed that the xseitenbilder extension (page images) always uses the original image and adds alternate width and height to resize. This might not work ideal with all images, some might be very large but displayed a lot smaller. :|
Throughout the code I changed the inclusion of images as follows:
Code:
while ($objSets->next()) {
$arrssettings[] = array
(
'width' => $objSets->width,
'height' => $objSets->height,
'defaultbild' => '[img]'.$objSets->defaultbild.'[/img]width.'" height="'.$objSets->height.'" alt="Default" title="Default"/>',
);
}
into:
Code:
while ($objSets->next()) {
$src = $this->getImage($this->urlEncode($objSets->defaultbild), $objSets->width, $objSets->height);
$size = getimagesize(TL_ROOT . '/' . $src);
$arrssettings[] = array
(
'width' => $size[0],
'height' => $size[1],
'defaultbild' => '[img]'.$src.'[/img]',
);
}
Doing this generates a smaller image that can be used. The image is also resized using TL methods preserving aspect ratios. With some alterations you can make xseitenbilder also use the type of resize (exact dimensions, proportional or fit box). But I didn't need that. ;)
Because I cannot reach the original author I added this fix here so anyone can apply it. :D
Re: [xseitenbilder] Code suggestion for better image support
Hi Vera,
I've added an extension to the repository that is exactly as the xseitenbilder, except it includes your sugestion. I also added some extra functionality to make the extension more flexible.
You can find it here: http://www.contao.org/extension-list/vi ... mages.html