Jump to:

7935 Posts in 1536 Topics by 943 members

DataObjectManager Module

SilverStripe Forums » DataObjectManager Module » Image Gallery : keep original size if Normal Size is much larger

Discuss the DataObjectManager module, and the related ImageGallery module.

Moderators: martimiz, UncleCheese, Sean, biapar, Willr, Ingo, swaiba, simon_w

Page: 1
Go to End
Author Topic: 1031 Views
  • Myrdhin
    Avatar
    Community Member
    67 Posts

    Image Gallery : keep original size if Normal Size is much larger Link to this post

    I have very little and big images in my album. I set "Normal Size" to 100px. But little images are pixelized when they are displayed...

    So i would like to keep image's original size when my "Normal Size" configuration is bigger than it.

    To do it, I modified "ImageGalleryPage.php" lines 272-275 :

    if($item->Image()->Landscape())
    $normalImg = $item->Image()->SetWidth($this->NormalSize);
    else
    $normalImg = $item->Image()->SetHeight($this->NormalSize);

    by

    $normalImg = $item->Image();
    if($item->Image()->Landscape() && ($item->Image()->getWidth() > $this->NormalSize) )
    $normalImg = $item->Image()->SetWidth($this->NormalSize);
    elseif ($item->Image()->getHeight() > $this->NormalSize)
    $normalImg = $item->Image()->SetHeight($this->NormalSize);

    Hope this help somebody !

    Is there another cleaner way to do that ? thanks.

  • UncleCheese
    Avatar
    4085 Posts

    Re: Image Gallery : keep original size if Normal Size is much larger Link to this post

    Interesting, but I have to ask... you're seriously displaying an image that is smaller than 100px in a lightbox?!

  • Myrdhin
    Avatar
    Community Member
    67 Posts

    Re: Image Gallery : keep original size if Normal Size is much larger Link to this post

    hu hu

    No, it was juste an example. In fact, i had set NormalSize to 250px and some little images to 100 and 120px.

    ps : Perhaps we could add a configuration checkbox like "set Normal Size as Max size". Another possibility will be an option "keep original size" for example.

    1031 Views
Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.