Diff. thumbsize landscape/portrait

snoep / 2011-02-23 11:36:19   

Hey all,

I am looking for a way to change media.php to deliver 2 different thumbsizes for landscape images and portrait images.

Due to a given Layout of this Webpage (see "Projekte") portrait images are allowed to have a maxheight of 375, while landscape images have 500px.

I need this, because I want 3 image sizes:
1st systhumb (75px)
2nd large image (375/500)
3rd a very large image (say 1000/600) w/ thickbox effect when clicking on the large image.

Any idea? I was thinking of an if-function somewhere around line 134??

thx!

Vaska A / 2011-02-24 06:04:35   

I'm trying to remember how I have done this in the past...

I simply adapated whatever function that resizes the image and does the output. Then I added it to the list of things in the uploader() function (I think that's what it's called).

snoep / 2011-02-24 06:09:55   

Hey Vaska,
thanks for the answer. I think the way to go is checking wether $thumb==true when calling the resizing function.
Then change $maxwidth to something appropriate. This would then be hard coded.
Otherwise I would have 2 differnent sizes in default.php .
1 for portrait, 1 for landscape ... This seems the easiest way to me right now.

Cheers.

Vaska A / 2011-02-24 06:14:34   

You could run a check in the function if the image is tall or wide (or square) and deal with things accordingly...like...

  1. $size = getimagesize( full_path_to_image );
  2. // if taller
  3. if ($size[1] > $size[0])
  4. {
  5. }
  6. // wider
  7. elseif ($size[0] > $size[1])
  8. {
  9. }
  10. else // default
  11. {
  12. }

Maybe this is helpful... ;)

snoep / 2011-02-24 08:46:18   

... it is; thx! though I wönder where the best place is to set the max height for portraits. Maybe I try it with a global var in defaults.php.

Thx, again.

Vaska A / 2011-02-24 08:52:20   

Yeah, you could create a new default in that file...then use it as you need.

This thread has been closed, thank you.