Class: Jekyll::SrcsetTag
- Inherits:
-
Liquid::Tag
- Object
- Liquid::Tag
- Jekyll::SrcsetTag
- Defined in:
- lib/jekyll/image_optimizer.rb
Instance Method Summary collapse
-
#initialize(tag_name, markup, tokens) ⇒ SrcsetTag
constructor
A new instance of SrcsetTag.
- #render(context) ⇒ Object
Constructor Details
#initialize(tag_name, markup, tokens) ⇒ SrcsetTag
Returns a new instance of SrcsetTag.
40 41 42 |
# File 'lib/jekyll/image_optimizer.rb', line 40 def initialize(tag_name, markup, tokens) super end |
Instance Method Details
#render(context) ⇒ Object
44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/jekyll/image_optimizer.rb', line 44 def render(context) s='' base_url=context['site']['baseurl'] index=Liquid::Template.parse(@markup).render(context).to_i src=context['page']['image'][index]['url'] hash=ImageHash.new(use_hash(context['site'])) for file in Dir[hash.dir_search_pattern(opt_dir(context['site'])+'*', src)] if File.file? file and hash.hash? file img=Magick::Image.ping(file).first s+=base_url+'/'+file+' '+img.columns.to_s+'w,' end end s[0..-2] end |