Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

We've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

DataObjectManager Module /

Discuss the DataObjectManager module, and the related ImageGallery module.

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

Image Gallery : keep original size if Normal Size is much larger


Go to End


3 Posts   1448 Views

Avatar
Myrdhin

Community Member, 70 Posts

27 February 2010 at 10:55am

Edited: 27/02/2010 10:58am

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.

Avatar
UncleCheese

Forum Moderator, 4102 Posts

27 February 2010 at 12:09pm

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

Avatar
Myrdhin

Community Member, 70 Posts

27 February 2010 at 12:23pm

Edited: 27/02/2010 12:25pm

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.