From fdf0ef736534e3400785259de86c6743e117d422 Mon Sep 17 00:00:00 2001 From: Zdzisiu <30577154+Zdzisiu@users.noreply.github.com> Date: Thu, 11 Jan 2024 22:18:42 +0100 Subject: [PATCH] #187 and #189 fix --- classes/Options.php | 12 ++++++++++++ classes/XHTMLFormatter.php | 13 +++++++++++++ conf/default.php | 1 + conf/metadata.php | 10 ++++++++++ screen.less | 20 +++++++++++++++++++- 5 files changed, 55 insertions(+), 1 deletion(-) diff --git a/classes/Options.php b/classes/Options.php index 2cae4e7..6d3b9cd 100644 --- a/classes/Options.php +++ b/classes/Options.php @@ -15,6 +15,10 @@ class Options public const ALIGN_RIGHT = 2; public const ALIGN_CENTER = 3; + public const ALIGNV_TOP = 'top'; + public const ALIGNV_BOTTOM = 'bottom'; + public const ALIGNV_CENTER = 'middle'; + // defaults public $galleryID = ''; public $thumbnailWidth = 120; @@ -37,6 +41,7 @@ class Options public $offset = 0; public $paginate = 0; public $align = self::ALIGN_FULL; + public $alignV = self::ALIGNV_CENTER; /** * Options constructor. @@ -51,6 +56,7 @@ public function __construct() $this->lightboxHeight = $plugin->getConf('image_height'); $this->columns = $plugin->getConf('cols'); $this->sort = $plugin->getConf('sort'); + $this->alignV = $plugin->getConf('alignV'); $this->parseParameters($plugin->getConf('options')); } @@ -82,6 +88,12 @@ public function parseParameters($params) $this->align = self::ALIGN_CENTER; } elseif ($param == 'full') { $this->align = self::ALIGN_FULL; + } elseif ($param == 'bottom') { + $this->alignV = self::ALIGNV_BOTTOM; + } elseif ($param == 'top') { + $this->alignV = self::ALIGNV_TOP; + } elseif ($param == 'middle') { + $this->alignV = self::ALIGNV_CENTER; } elseif (preg_match('/^=(\d+)$/', $param, $match)) { $this->limit = (int)$match[1]; } elseif (preg_match('/^\+(\d+)$/', $param, $match)) { diff --git a/classes/XHTMLFormatter.php b/classes/XHTMLFormatter.php index 953481f..96b60d7 100644 --- a/classes/XHTMLFormatter.php +++ b/classes/XHTMLFormatter.php @@ -136,6 +136,19 @@ protected function renderImage(Image $image) // figure properties $fig = []; $fig['class'] = 'gallery-image'; + + switch ($this->options->alignV) { + case Options::ALIGNV_CENTER: + $fig['class'] .= ' alignv-middle'; + break; + case Options::ALIGNV_TOP: + $fig['class'] .= ' alignv-top'; + break; + case Options::ALIGNV_BOTTOM: + $fig['class'] .= ' alignv-bottom'; + break; + } + if ($this->options->align !== Options::ALIGN_FULL) { $fig['style'] = 'max-width: ' . $this->options->thumbnailWidth . 'px; '; } diff --git a/conf/default.php b/conf/default.php index 248fa53..d5660f3 100644 --- a/conf/default.php +++ b/conf/default.php @@ -11,6 +11,7 @@ $conf['image_width'] = 1600; $conf['image_height'] = 1200; $conf['cols'] = 0; +$conf['alignV'] = 'middle'; $conf['sort'] = 'file'; $conf['options'] = 'cache, crop, lightbox'; diff --git a/conf/metadata.php b/conf/metadata.php index 331a4d2..121d744 100644 --- a/conf/metadata.php +++ b/conf/metadata.php @@ -24,6 +24,16 @@ Options::SORT_RANDOM, ) ); + +$meta['alignV'] = array( + 'multichoice', + '_choices' => array( + Options::ALIGNV_TOP, + Options::ALIGNV_CENTER, + Options::ALIGNV_BOTTOM, + ) +); + $meta['options'] = array('multicheckbox', '_choices' => array( 'cache', 'crop', diff --git a/screen.less b/screen.less index fabd9a2..29e0d54 100644 --- a/screen.less +++ b/screen.less @@ -36,7 +36,6 @@ div.plugin-gallery { margin: 0; padding: 0.4em; display: flex; - flex-direction: column; justify-content: space-between; overflow: hidden; @@ -56,6 +55,22 @@ div.plugin-gallery { } } } + + &.alignv-middle { + align-items: center; + } + + &.alignv-top { + flex-direction: column; + } + + &.alignv-bottom { + flex-direction: column-reverse; + } + + &.empty { + border: 0; + } } } @@ -66,17 +81,20 @@ div.plugin-gallery { &.align-left { float: left; margin-right: 1em; + width: 100%; } &.align-right { float: right; margin-left: 1em; + width: 100%; } &.align-center { display: flex; justify-content: center; flex-wrap: wrap; // wrap page selector on new line + width: 100%; } .gallery-page-selector {