diff --git a/README.md b/README.md index c816c5b..b545acd 100644 --- a/README.md +++ b/README.md @@ -27,7 +27,7 @@ Automagical css image gallery in [Hugo](https://gohugo.io/) using shortcodes, wi - Put multiple `{{< figure >}}` shortcodes inside a `{{< gallery >}}` to create a pretty image gallery - **Point `{{< gallery >}}` at a directory to generate a gallery of all images in that directory** - Gallery is responsive, images are scaled/cropped to fill square (or other evenly-sized) tiles -- Pretty captions appear/slide/fade upon hovering over the image +- Pretty captions appear/slide/fade upon hovering over the image - Optionally make gallery images zoom, grow, shrink, slide up, or slide down upon hover - Only requires 3.6kB of CSS (unminified; you can minify it if you want) - CSS is automatically loaded the first time you use the `{{< figure >}}` shortcode on each page @@ -92,10 +92,10 @@ Optional parameters: - `size` (e.g. `size="1024x768"`) pre-defines the image size for PhotoSwipe. Use this option if you don't want to pre-load the linked image to determine its size. - `class` allows you to set any custom classes you want on the `
` tag. -Optional parameters for standalone `{{< figure >}}` shortcodes only (i.e. don't use on `{{< figure >}}` inside `{{< gallery >}}` - strange things may happen if you do): +Optional parameters for standalone `{{< figure >}}` shortcodes only (i.e. don't use on `{{< figure >}}` inside `{{< gallery >}}` - strange things may happen if you do): -- `caption-position` and `caption-effect` work the same as for the `{{< gallery >}}` shortcode (see below). -- `width` defines the [`max-width`](https://www.w3schools.com/cssref/pr_dim_max-width.asp) of the image displayed on the page. If using a thumbnail for a standalone figure, set this equal to your thumbnail's native width to make the captions behave properly (or feel free to come up with a better solution and submit a pull request :-)). Also use this option if you don't have a thumbnail and you don't want the hi-res image to take up the entire width of the screen/container. +- `caption-position` and `caption-effect` work the same as for the `{{< gallery >}}` shortcode (see below). +- `width` defines the [`max-width`](https://www.w3schools.com/cssref/pr_dim_max-width.asp) of the image displayed on the page. If using a thumbnail for a standalone figure, set this equal to your thumbnail's native width to make the captions behave properly (or feel free to come up with a better solution and submit a pull request :-)). Also use this option if you don't have a thumbnail and you don't want the hi-res image to take up the entire width of the screen/container. - `class="no-photoswipe"` prevents a `
` from being loaded into PhotoSwipe. If you click on the figure you'll instead a good ol' fashioned hyperlink to a bigger image (or - if you haven't specified a bigger image - the same one). ## `{{< gallery >}}` shortcode usage @@ -141,6 +141,8 @@ Optional parameters: - `hover-transition` - determines if/how images change upon hover. Options: - not set - smooth transition (default) - `none` - hard transition +- `thumbnail-size` sets the size of the thumbnails for the gallery. Default is "300x300". First number is width, second number is height. + - example: `{{< gallery dir="/img/your-directory-of-images/" thumbnail-size="150x150" />}}` ## PhotoSwipe usage diff --git a/layouts/shortcodes/gallery.html b/layouts/shortcodes/gallery.html index aac2ace..66a90e2 100644 --- a/layouts/shortcodes/gallery.html +++ b/layouts/shortcodes/gallery.html @@ -3,9 +3,10 @@ Documentation and licence at https://github.com/liwenyip/hugo-easy-gallery/ --> -{{- if not ($.Page.Scratch.Get "figurecount") }}{{ end }} -{{- $.Page.Scratch.Add "figurecount" 1 }} -{{ $baseURL := .Site.BaseURL }} +{{- if not ($.Page.Scratch.Get "figurecount") -}}{{- end -}} +{{- $.Page.Scratch.Add "figurecount" 1 -}} +{{- $baseURL := .Site.BaseURL -}} +{{- $thumbnailSize := .Get "thumbnail-size" | default "300x300" -}}