mattvh / JekyllGalleryTag

Jekyll plugin to generate thumbnails from a directory of images and display them with a Liquid tag
74 stars 18 forks source link

JekyllGalleryTag

Jekyll plugin to generate thumbnails from a directory of images and display them with a Liquid tag

Installation

  1. Install ImageMagick and the RMagick gem.
  2. Drop galleries.rb into your Jekyll site's _plugins folder.
  3. Add the following to your _config.yml and customize to taste.
gallerytag:
    dir: images/galleries
    url: /images/galleries
    thumb_width: 150
    thumb_height: 150
    columns: 4

Usage

Jekyll will automatically generate (during builds) thumbnails for any images in the folder specified in _config.yml. To display them in a post, you would use a Liquid tag set up like this:

{% gallery galleryname %}
subfolder/myfirstimage.jpg:: A caption!
subfolder/myseconfimage.png:: Another caption
subfolder/mythirdimage.jpg
subfolder/myfourthimage.png
subfolder/myfifthimage.jpg
{% endgallery %}

Jekyll will output some HTML that is (intentionally) similar to what WordPress does for galleries in posts, making it relatively simple to tweak your CSS. It will also add rel attributes to the links, which contain the "galleryname" text as shown in the above example. This makes is easy to integrate a lightbox script like FancyBox.

You can see it in action on my personal blog, here.