As mentioned in a previous post, I moved to hexo partly because I wanted to make image galleries work.
As it turns out, the landscape theme has already laid the groundwork by including fancybox so you can conveniently add something like this to your front matter:
|
|
and place the relevant photos in /source/images/
. Now if you click on the first image on the top of the post you will get a default fancybox gallery. However, this does not allow you to add annotations or captions.
What would be preferable would be a gallery with thumbnails and captions:
This should looks something like this:
|
|
What I also wanted to achieve was to separate the images into multiple galleries, be it on the same page or on the home page. Using the fancybox
tag as above leads to the unexpected result that all images on the page will end up in a single gallery. This is a side effect of the theme trying to ensure that the galleries from individual posts are in separate galleries on the home page. It does this in themes/landscape/js/script.js
by iterating over all images in each article and setting their rel
link to a unique id for each article, overwriting any pre-existing rel
links in the process. The fix looks like this:
1 Copy the themes/landscape/scripts/fancybox.js
to create a new tag. Let’s call it fancybox2
|
|
2 Modify themes/landscape/source/js/script.js
to append to the existing rel
link instead of overwriting it.
|
|
And voila, we can have another separate gallery …