Generates a gallery view of selected pages based on images found in them.
Warning: This plugin is in development and should be considered unstable! Always make a backup of your vault before testing out a new plugin.
Depends on obsidian-dataview to list pages and page metadata.
Create a code block with type page-gallery
:
```page-gallery
# Any options given at the root level of the configuration
# will be used as defaults for all views (but can be overridden
# in any individual view).
fields: [file.name]
columns: 3
orientation: landscape
# If you don't include an explicit `views` option (which needs
# to be an array), then page-gallery will just use all the root
# level options as a single unnamed view.
views:
- name: Yosemite
from: '"Images" AND #yosemite'
- name: Yellowstone
from: '"Images" AND #yellowstone'
columns: 4
orientation: portrait
```
Photos from Unsplash and Pixabay
Options in the page-gallery
block are parsed using YAML.
Option | Type | Default | Description |
---|---|---|---|
title |
string |
null |
An optional title for the page gallery. |
filter |
boolean |
true |
Whether or not to show the filter bar. |
debug |
boolean |
false |
Whether or not to display debug information. Useful primarily for development. |
views |
ViewConfig[] |
[] |
A list of individual view configuration blocks (see below). |
A page gallery consists of a list of views (or tabs), each with its own view settings. Valid view settings are listed below. Any of this view settings can be set in the root of the configuration as well, in which case they act as defaults for all defined views.
If no views are defined, the page gallery will have a single view, based on the values defined in the root configuration.
Option | Type | Default | Description |
---|---|---|---|
name |
string |
"View #" |
Optional name or title for the view. |
mode |
`"auto" | "image" | "content"` |
from |
string |
- | Query for pages to include in the gallery. Uses the same query syntax as obsidian-dataview. |
where |
string |
- | Additional expression to filter out pages that you want to omit from the gallery. |
fields |
string[] |
[] |
List of fields to display in the gallery, under the image. Supports both frontmatter and inline fields. |
limit |
number |
100 |
Limit on the number of pages that will be displayed in the gallery. Set this to null to display all of the pages matched by the from query. |
groupBy |
string |
- | Groups pages by a particular field (or obsidian-dataview expression). |
sortBy |
string[] |
['file.path'] |
One or more fields/expressions to sort the pages by. Prefix with a - sign (e.g. -file.path ) to reverse the sort order. |
columns |
number |
4 |
Number of columns to display at full width. |
gutterSize |
string |
"16px" |
Size of the gutter between images. |
orientation |
`"portrait" | "landscape"` | "portrait" |
radius |
string |
"10px" |
Radius of the corners of each tile. |
width |
string |
Calculated from columns and gutterSize . |
Display width of each image in the gallery. Overrides columns . |
height |
string |
Calculated from imageWidth . |
Display height of each image in the gallery. |
size |
string |
cover |
How the image should be scaled to fit within the gallery tile. See CSS background-size for available options. |
position |
string |
center |
Positioning of each image in the gallery. Try top , center , or bottom (etc) to change what parts of the images are visible. See CSS background-position for available options. |
repeat |
string |
no-repeat |
Whether to repeat (i.e. tile) the image in each gallery item. See CSS background-repeat for available options. |
Additionally, the size
, position
, and repeat
values can be overridden on
a specific page via YAML frontmatter:
---
pageGallery:
size: contain
position: left
repeat: repeat-x
---
Caution: This will override those settings for any page gallery that the page appears in.