Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
Zdzisiu committed Jan 11, 2024
1 parent 231056a commit fdf0ef7
Show file tree
Hide file tree
Showing 5 changed files with 55 additions and 1 deletion.
12 changes: 12 additions & 0 deletions classes/Options.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -37,6 +41,7 @@ class Options
public $offset = 0;
public $paginate = 0;
public $align = self::ALIGN_FULL;
public $alignV = self::ALIGNV_CENTER;

/**
* Options constructor.
Expand All @@ -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'));
}

Expand Down Expand Up @@ -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)) {
Expand Down
13 changes: 13 additions & 0 deletions classes/XHTMLFormatter.php
Original file line number Diff line number Diff line change
Expand Up @@ -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; ';
}
Expand Down
1 change: 1 addition & 0 deletions conf/default.php
Original file line number Diff line number Diff line change
Expand Up @@ -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';
10 changes: 10 additions & 0 deletions conf/metadata.php
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
20 changes: 19 additions & 1 deletion screen.less
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ div.plugin-gallery {
margin: 0;
padding: 0.4em;
display: flex;
flex-direction: column;
justify-content: space-between;
overflow: hidden;

Expand All @@ -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;
}
}
}

Expand All @@ -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 {
Expand Down

0 comments on commit fdf0ef7

Please sign in to comment.