Results 1 to 2 of 2

Thread: [xseitenbilder] Code suggestion for better image support

  1. #1
    User
    Join Date
    06-29-09.
    Posts
    271

    Default [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

  2. #2
    Experienced user
    Join Date
    01-12-10.
    Posts
    814

    Default 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

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •