Sha256: 3d4078e658c680875fdb5d7d13cfa2231f3a4a8bf2a911728c360798e19ebae1
Contents?: true
Size: 755 Bytes
Versions: 2
Compression:
Stored size: 755 Bytes
Contents
module Jekyll module AssetFilter require 'jekyll' require 'nokogiri' def img_prefix(content) img_url = @context.registers[:site].config['img_prefix'] return content unless img_url doc = Nokogiri::HTML.fragment(content) return content unless doc doc.css('img').each do |img| original_url = img.get_attribute("src") next if original_url =~ /\Ahttp/i new_url = img_url.to_s + relative_url(original_url) img.set_attribute('src', new_url) end doc.to_s end def img_url_prefix(input) img_url = @context.registers[:site].config['img_prefix'] img_url.to_s + relative_url(input) end end end Liquid::Template.register_filter(Jekyll::AssetFilter)
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
jekyll-img-prefix-0.1.2 | lib/jekyll-img-prefix.rb |
jekyll-img-prefix-0.1.1 | lib/jekyll-img-prefix.rb |