Categories
Pro

How to Have Images Dynamically Resize Based on Remaining Space on the Page

Print My Blog (PMB) 3.11.0 quietly introduced a new feature: dynamic image resizing. PMB 3.12.0 made using it a breeze. So what is dynamic image resizing and why would you want it?

What Is Dynamic Image Resizing

One of the biggest troubles when printing out WordPress content is avoiding whitespace. Wouldn’t it be great if you could have PMB automatically shrink images to fill in that whitespace (provided they wouldn’t be too small, of course)? That’s what dynamic image resizing is!

A layout with two big chunks of whitespace in front of a big image. Yuck.

How To Use It

First, you need to be using a design that has the “Image Placement” setting—the Classic Digital PDF and Classic Print-Ready PDF are two of them.

Find your project and go to its “Customize Digital PDF Design” or “Customize Print-Ready PDF Design” (whichever you’re using―if you’re using both, go ahead and do this for both.) Then expand “Image Settings”.

A project’s “Customize Print-Ready PDF Design” after selecting the Classic Print PDF.

For the “Image Placement” setting, set it to “Resize images if they don’t fit on the page.”

On the Classic Print-Ready and Classic Digital PDFs, the “Image Placement” setting has a new option of “Resize Images if they don’t fit on the page.” Selecting this enables dynamic image resizing.

You’ll see another setting appear, “Minimum Image Size (in pixels)”. Any image bigger than this (that’s not part of a gallery or in column blocks) will be shrunk as much as necessary in order to fit on the page they’re originally placed on, provided they won’t be smaller on this. So if it’s set to 300 (pixels), any image over 300 pixels tall will be “dynamically resized”. And when resizing them, they’ll be at least 300 pixels tall. If there’s not 300 pixels of space on the page, they’ll be bumped to the next page.

The “Minimum Image Size (in pixels)” setting appears when you select “Resize images if they don’t fit on the page”.

Some Samples

It might help to see dynamic image resizing in action. One important thing to note: when you set the minimum image size, that size will take the image’s caption into account. So if you set a minimum size of 300 pixels, it will squeeze the image and caption into 300 pixels; if there’s not 300 pixels of space left on the page, it will be bumped to the next page.

Compare this screenshot to the one earlier with the whitespace. This one uses dynamic image resizing to shrink the first 3 images to totally remove dead whitespace from the pages.

Dynamic image resizing works well on left-aligned or right-aligned images as well, arguably better. Even the whitespace beside the images can usually be totally removed when using images that float to one side or the other.

This screenshot has a bit of dead whitespace and two images that are left-aligned, but take up the entire page width so you don’t see it here. This layout could benefit from some dynamic image resizing…
The left-aligned images were resized to extend only down to the bottom of the page, and because they’re all left-aligned the text wraps nicely around the 1st highlighted one, and the 2nd and 3rd highlighted images are able to stack side-by-side.

A few Important Notes about Dynamic Resizing Image

Dynamic resizing images doesn’t apply to galleries or images inside column blocks. For the best layout with these, you’re probably best adding the CSS classes pmb-float-top or pmb-float-bottom to allow text to flow in front of them to fill in whitespace.

Dynamic image resizing will also not stretch images beyond their natural size. For example, if you upload an 500x500image to your website and use it in a project, and are using dynamic image resizing, that image will not be stretched longer than 800 pixels tall. Doing so would always look pixelated. Dynamic image resizing will only shrink images to make them fit onto the page.

If you would like to see which images are being dynamically resized, you can add the following CSS to your design:

.pmb-dynamic-resize{
    border:1px solid red;
}
.pmb-dynamic-resized{
    border:1px solid green;
}

This will put a red border around images before they are resized and a green border after they are resized.

Lastly, if you want an image to be an exception and dynamically resized it, add the CSS class pmb-dont-dynamic-resize onto it.

How To Use It in Conjunction with Maximum Image Height

The setting “Maximum Image Height (in pixels) can be used alongside dynamic image resizing (in designs that have this setting, like the Classic Digital PDF and Classic Print-Ready PDF).

Design settings setting the minimum image height to 300 pixels and the maximum image height to 500 pixels.

By setting a maximum and minimum image height, you can a set a range for acceptable image sizes in your documents, so they don’t look too big or too small.

The only exception is images which are naturally smaller than the minimum image size. Like mentioned earlier, images will not be stretched. So if you’d like a small image to become bigger you will need to upload a higher resolution image to your website to replace the lower resolution image you currently have.

Conclusion

Dynamic image resizing can be a useful tool to remove dead whitespace from your documents created in PMB and I hope you find it useful. Please let me know how it works for you and if you have any suggestions on how to improve it further.

3 replies on “How to Have Images Dynamically Resize Based on Remaining Space on the Page”

[…] Mark realized big areas of whitespace preceding images didn’t look very professional. Print My Blog’s way of dealing with that was by allowing text to flow around images, filling in the blank space at the end of pages preceding images when needed. But using this feature meant Mark couldn’t know if a paragraph of text would appear before or after an image, or on the same page, which wasn’t how he was accustomed to writing. (Print My Blog now has a feature that will dynamically resize images according to the remaining space….) […]

Leave a Reply

Your email address will not be published. Required fields are marked *