processwire-requests icon indicating copy to clipboard operation
processwire-requests copied to clipboard

Please add ->isPortrait property to Pageimage objects

Open BernhardBaumrock opened this issue 9 months ago • 2 comments

Often in designs we have to treat images differently if they are higher than wide. Code like this bloats templates and needs more cognitive power to understand:

if($img->height > $img->width) {
   ...
}

It would be great to have an "isPortrait" property:

if($img->isPortrait) {
   ...
}

BernhardBaumrock avatar Mar 31 '25 18:03 BernhardBaumrock

This one will be very handy if added.

gideonso avatar Apr 01 '25 03:04 gideonso

@BernhardBaumrock I add a hook that creates a property/method to work with all orientations in pretty much every project now. Perhaps provides more utility, or present in addition to isPortrait?

$image->orientation;   // 'portrait', 'landscape', 'square'

$image->orientation();            // 'portrait, 'landscape', 'square'
$image->orientation('portrait');  // boolean
$image->orientation('landscape'); // boolean
$image->orientation('square');    // boolean

SkyLundy avatar Aug 23 '25 17:08 SkyLundy