Jump to content

nick graham photographer site


benbyf
 Share

Recommended Posts

hi benbyf,

the images are tremendously huge!! the first for example is 2248x3000 @ 1.9MB

it's so easy to fix this with PW:

<img src="<?= $page->your_image->size(1000, 1000, array('cropping' => false))->url ?>" alt="...">

and it will keep its aspect ratio. keep in mind that on first load it will need lots of memory + cpu so there may be some timeouts, but when all the images are resized the following pageloads will be faster :)

  • Like 3
Link to comment
Share on other sites

"the images are tremendously huge!! the first for example is 2248x3000 @ 1.9MB"

With tinypng/tinyjpg it becomes 189.0 KB (−91%)...

@bernhard:

<img src="<?= $page->your_image->size(1000, 1000, array('cropping' => false))->url ?>" alt="...">

Does this code mean that the dimension closest to 1000 will have this value, and that the other dimension's new value will be proportional?

Edit: the opposite had more sense.

  • Like 1
Link to comment
Share on other sites

The owner of the site is a professional photographer, who needs to show (his) images at its best. And I suppose that his main clients are agencies / artdirectors who uses 30" monitors. Any regular "webimageshrinkingtool" is counterproductive here, I believe. :)

  • Like 3
Link to comment
Share on other sites

@horst

if that kind of full res images are really needed i would present lower quality images and make a link somewhere "show/download full res image", don't you think?

@chris

have a look at the docs. all the options and what they do are well explained here: https://processwire.com/api/fieldtypes/images/

edit: my example creates a new image with maximum dimensions of 1000px (height OR width) and keeping the original aspect ratio

3000x2000 would get 1000x666

2000x3000 would get 666x1000

500x500 would get 500x500 (see option "upscaling")

  • Like 1
Link to comment
Share on other sites

@bernhard

You could also use the maxSize method:

$thumb = $image->maxSize($width, $height); 

This method does also resizing without cropping.

Too bad this nice method is only documented in the blog post and cannot be found through the site search. Hopefully the documentation will be updated with the stable release of ProcessWire 3.

  • Like 1
Link to comment
Share on other sites

@bernhard

I had seen the page https://processwire....ldtypes/images/.

The fact that until now, I have most often, if not always, "deactivated" these kinds of options in config.php (like cropping and other ones) and that the times I have used size, with the width and height chosen and/or with the dimensions of the images, I haven't had the opportunity to notice how it really worked, made me think that it was something different. I simply haven't used it enough. :)

  • Like 1
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...