From: Marek Bachmann Date: Mon, 12 Dec 2022 23:39:39 +0000 (+0100) Subject: Fixed image grid when exactly ONE portrait and ONE landscape is attached X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=290b14a000e794d0c0805453800b965a65cf26c4;p=friendica.git Fixed image grid when exactly ONE portrait and ONE landscape is attached --- diff --git a/src/Model/Item.php b/src/Model/Item.php index f24771375d..69b1595c20 100644 --- a/src/Model/Item.php +++ b/src/Model/Item.php @@ -3175,13 +3175,22 @@ class Item // Mix of landscape and portrait images. if ($lcount == $pcount) { // equal amount of landscapes and portraits - for ($l = 0; $l < $lcount; $l++) { - if ($l % 2 == 0) { - $images_fc[] = $landscapeimages[$l]; - $images_fc[] = $portraitimages[$l]; - } else { - $images_sc[] = $portraitimages[$l]; - $images_sc[] = $landscapeimages[$l]; + if ($lcount == 1) { + // one left / one right + $images_fc[] = $landscapeimages[0]; + $images_sc[] = $portraitimages[0]; + } else { + // Distribute equal to both columns + for ($l = 0; $l < $lcount; $l++) { + if ($l % 2 == 0) { + // landscape left and portrait right for even numbers + $images_fc[] = $landscapeimages[$l]; + $images_fc[] = $portraitimages[$l]; + } else { + // portraits left and landscape right for odd numbers + $images_sc[] = $portraitimages[$l]; + $images_sc[] = $landscapeimages[$l]; + } } } }