zenphoto forums » Feature Requests

Set maximum image height and width?

(16 posts)
  1. Andrew

    Junior
    Joined: Oct '07
    Posts: 6

    Hey, all -- I've been reading various posts in the forum but haven't found one that helps with this problem.

    I want to change ZenPhoto's sizing behavior so that no image is more than 800 pixels wide and no more than 494 pixels high. Right now it seems I have the option to set either the maximum width or the maximum for both. There's no separate setting for max height.

    (I read the thread at http://www.zenphoto.org/support/topic.php?id=640&replies=25#post-3739, but it didn't help.)

    I want ZenPhoto to shrink the photo so that the height is <= 494 and the width is <= 800. Obviously this is so that both portrait and landscape images fit in the window.

    Anything someone can suggest or point me to? Many thanks!

    http://www.zenphoto.org/support/topic.php?id=640&replies=25#post-3739

    Posted 5 years ago #
  2. Zenphoto development team
    acrylian

    Developer
    Joined: Jul '07
    Posts: 13,341

    I did this with PHP like this:
    <?php
    $percent = getFullWidth() / 100; // getting 1 percent from the width
    $heightpercent = getFullHeight() / $percent; // getting how many percent the height of the width;
    // if the image is a quadrat
    if (getFullWidth() === getFullHeight())
    {
    printCustomSizedImage(getImageTitle(), 800, 800, 494, null, null, null, null, getImageID());
    }
    // the height should never be more than 61 percent (494 are 61.75 percent from maxwidth 800)
    elseif ($heightpercent >= 61)
    {
    printCustomSizedImage(getImageTitle(),null, null, 494, null, null, null, null, getImageID());
    }
    else
    {
    // if the image fits normally, so that it can't get too wide
    printCustomSizedImage(getImageTitle(), 800, 800, 494, null, null, null, null, getImageID());
    }
    ?>

    Could be that you need to adjust the values a little.

    Don't forget to read the Forum rules and usage resources
    Posted 5 years ago #
  3. Zenphoto development team
    acrylian

    Developer
    Joined: Jul '07
    Posts: 13,341

    quadrat should read square of course (sorry, my german played tricks with me...)

    Don't forget to read the Forum rules and usage resources
    Posted 5 years ago #
  4. Andrew

    Junior
    Joined: Oct '07
    Posts: 6

    Thanks! Now, If I could put on my stupid hat for a moment, into which file should I put that? My image.php, or into one of ZenPhoto's files?

    Posted 5 years ago #
  5. Zenphoto development team
    acrylian

    Developer
    Joined: Jul '07
    Posts: 13,341

    Oh, I forgot, put it into your image.php like this:
    <div id="image">
    <a href="<?php echo getFullImageURL();?>" title="<?php echo getImageTitle();?>">
    <PUT HERE THE ABOVE CODE>
    </div>

    Don't forget to read the Forum rules and usage resources
    Posted 5 years ago #
  6. Andrew

    Junior
    Joined: Oct '07
    Posts: 6

    Wonderful -- thank you!

    Posted 5 years ago #
  7. Joen

    Member
    Joined: Sep '05
    Posts: 43

    Great stuff here. Acrylians code cropped things strangely, for me, though, so I made my own variation.

    The following code looks at whether the image is square, portrait or landscape, and based on some variables you configure, sizes the image accordingly.

    <div id="image" align="center">
    <a href="<?php echo getFullImageURL();?>" title="<?php echo getImageTitle();?>">
    <?php
    $maxwidth = 700;
    $maxheight = 470;
    $maxar = $maxwidth / $maxheight;
    $fullwidth = getFullWidth();
    $fullheight = getFullHeight();
    $fullar = $fullwidth / $fullheight;
    // if image is square
    if ($fullwidth == $fullheight) {
    printCustomSizedImage(getImageTitle(), null, null, $maxheight, null, null, null, null, getImageID());
    }
    // if image is landscape
    else if ($fullar >= $maxar) {
    printCustomSizedImage(getImageTitle(), $maxwidth, $maxwidth, mull);
    }
    // if image is portrait
    else if ($fullar <= $maxar) {
    printCustomSizedImage(getImageTitle(), null, null, $maxheight);
    }
    ?>
    </a>
    </div>

    Posted 4 years ago #
  8. Zenphoto development team
    acrylian

    Developer
    Joined: Jul '07
    Posts: 13,341

    That code is old and indeed not optimal. But I really would like to suggest to look at our functons guide, we have already a function for that:
    http://www.zenphoto.org/documentation-official/zenphoto/_template-functions.php.html#functionprintCustomSizedImageMaxHeight

    Don't forget to read the Forum rules and usage resources
    Posted 4 years ago #
  9. eddiejanzer

    Senior
    Joined: Jun '06
    Posts: 63

    I looked at the documentation and am confused here. I'm hoping I can resolve this for my sub albums. I don't want my images cropped but I want 220px wide on my landscape, and my portrait to be no taller than my landscaped (180px). I have been using this '<?php printCustomAlbumThumbImage(getAlbumTitle(), null, null, 240); ?>' . Any help would be appreciated.

    Posted 4 years ago #
  10. eddiejanzer

    Senior
    Joined: Jun '06
    Posts: 63

    ok, what I wanted wasn't so difficult. sorry

    Posted 4 years ago #
  11. jayray999

    Contributor
    Joined: Aug '06
    Posts: 165

    In this entire comment PORTRAIT refers to portrait orientation (image height > image width) and LANDSCAPE to landscape orientation (image height < image width).

    People who visit my gallery get frustrated if they have to scroll down to see the entire PORTRAIT image. Currently the only way to avoid this is to specify a low number (say 595px) which applies both to image height and width. This solves the scrolling problem in the case of PORTRAITS but in turn LANDSCAPES become unnecessarily small. This is also currently an issue in the SLIDESHOW plugin where the sudden appearance of a scroll bar in certain images causes the entire slideshow to shift in an unsightly fashion.

    What would be nice:

    A way to maximize the use of browser-window real estate i.e the displayed image (regardless of orientation) should use as much of the available browser window as possible without the user needing to scroll. This should be an option both in regular image galleries and slideshows.

    Posted 4 years ago #
  12. Zenphoto development team
    acrylian

    Developer
    Joined: Jul '07
    Posts: 13,341

    @eddiejanzer: You can use this code to get a image in a given space w x h (this code is more effective than the function mentioned above):
    if (getFullWidth() === getFullHeight() OR getFullWidth() > getFullHeight()) { printCustomSizedImage(getImageTitle(), null, 150, null);
    } else {
    printCustomSizedImage(getImageTitle(), null, null , 150);
    }

    You can of course replace the used function with the printcustomalbumthumbimage one above. We will add this as default behavior in the future, meaning you will be able to set a width and height for uncropped thumbs/sized images instead of setting only a size sometime in the future.

    jayray999:
    To your browser window idea,. I think this could be done as a theme option. And you can do that with CSS alone, you just need to set the <img> and it's width/height attributes to a relative percentage for example. Then the image will scale if you change the browser window. You could even use max-width to prevent them getting too big if their resolution does not allow.

    Don't forget to read the Forum rules and usage resources
    Posted 4 years ago #
  13. jayray999

    Contributor
    Joined: Aug '06
    Posts: 165

    @acrylian: Hello on another thread. Well, I guess this can be our suggestion for theme designers to consider but I am hoping you think it is useful enough to be an option in the default theme. I can make a feature request if you want to make it formal.

    Posted 4 years ago #
  14. Zenphoto development team
    acrylian

    Developer
    Joined: Jul '07
    Posts: 13,341

    Creating a ticket does never hurt...:-) I can't promise if we do that, flexible layouts are a "science". Actually it also would be welcome if you try to make a custom theme..:-)

    Don't forget to read the Forum rules and usage resources
    Posted 4 years ago #
  15. nycreal

    Apprentice
    Joined: Jul '10
    Posts: 1

    I am reading every comment because I have a small geographically specific real estate MLS database with images that are actually on a different server so I have very little control over the way the images are displayed...I want to find out more about zenphoto CMS and php/mysql integration because I have the image URL's and the dimensions in an already existing database

    Posted 2 years ago #
  16. Zenphoto development team
    acrylian

    Developer
    Joined: Jul '07
    Posts: 13,341

    So what is your question actually? Seems it is not really on topic... Image must reside in the root albums folder so that Zenphoto recognizes them.

    Don't forget to read the Forum rules and usage resources
    Posted 2 years ago #

RSS feed for this topic

Reply

You must log in to post.