Skip to content

Instantly share code, notes, and snippets.

@BostonEnginerd
Created March 15, 2015 14:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save BostonEnginerd/311980c0bbd62bb46fbc to your computer and use it in GitHub Desktop.
Save BostonEnginerd/311980c0bbd62bb46fbc to your computer and use it in GitHub Desktop.
Adding a gallery to Pelican
Include the gallery and thumbnailer plugins.
Add the following to pelicanconf.py
THUMBNAIL_SIZES={'thumbnail_square': '100'}
At the bottom of the article template, add the following near the bottom of the content block:
{% if article.gallery %}
<section>
<div id="blueimp-gallery" class="blueimp-gallery">
<div class="slides"></div>
<h3 class="title"></h3>
<a class="prev">‹</a>
<a class="next">›</a>
<a class="close">×</a>
<a class="play-pause"></a>
<ol class="indicator"></ol>
</div>
<h3> Image Gallery</h3>
<div id="links">
{{ article.gallery_content }}
</div>
</section>
{% endif %}
In the script block, add:
{% if article.gallery %}
<script src="/theme/js/blueimp-gallery.min.js"></script>
<script>
document.getElementById('links').onclick = function (event) {
event = event || window.event;
var target = event.target || event.srcElement,
link = target.src ? target.parentNode : target,
options = {index: link, event: event},
links = this.getElementsByTagName('a');
blueimp.Gallery(links, options);
};
</script>
{% endif %}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment