Created
February 2, 2016 10:13
-
-
Save yortz/fdd0aaaa48ad92437e63 to your computer and use it in GitHub Desktop.
gallery tag plugin that integrates lightbox functionality to octopress image gallery
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
BASE_DIR = 'source/_assets/images/galleries' | |
module ImageList | |
def image_list( name ) | |
list = Array.new | |
dir = Dir.new( File.join(BASE_DIR, name) ) | |
dir.each do | d | | |
image = File.basename(d, File.extname(d)) | |
unless d =~ /^\./ || d =~ /thumbs/ | |
list << ["/images/galleries/#{name}/#{d}", "#{name}", "#{image}", "/images/galleries/#{name}/thumbs/#{d}"] | |
end | |
end | |
%Q{<script type="text/javascript"> | |
jQuery(document).ready(function() { | |
$('#gallery').hide(); | |
var images = #{list.sort}; | |
$(images).each(function() { | |
var $image = this[0]; | |
var $name = this[1]; | |
var $title = this[2].replace(/_/g, '%20'); | |
var $thumb = this[3]; | |
$('#gallery').append('<a class="fancy" href=' + $image + ' rel=' + $name + ' title =' + $title + '>' + '<img src=' + $thumb + ' class="noresize"' + '</a>'); | |
}); | |
jQuery('#gallery').waitForImages({ | |
finished: function() { | |
jQuery('#gallery').fadeIn("slow"); | |
var links = $('#gallery a'); | |
$(links).each(function(){ | |
title = unescape($(this).attr('title')); | |
$(this).attr('title', title); | |
}); | |
}, | |
waitForAll: true | |
}); | |
}); | |
</script>} | |
end | |
end | |
Liquid::Template.register_filter(ImageList) | |
module SiteAddress | |
def domain | |
domain << "http://yourdomain.ext" | |
end | |
end | |
Liquid::Template.register_filter(SiteAddress) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment