Sha256: 27377206ac98a4efd54119b7df15c399f8f9031b23590e26a75f8fa099186e5b
Contents?: true
Size: 1.06 KB
Versions: 1
Compression:
Stored size: 1.06 KB
Contents
# # add resize_to param to image_tag to create thumbnails # # # Usage: # = image_tag item.image, resize_to: '50x30', class: 'thumbnail' # module MiddlemanSimpleThumbnailer class Extension < Middleman::Extension def initialize(app, options_hash={}, &block) super app.after_build do |builder| MiddlemanSimpleThumbnailer::Image.all_objects.each do |image| builder.say_status :create, "#{image.resized_img_path}" image.save! end end end helpers do def image_tag(path, options={}) resize_to = options.delete(:resize_to) return super(path, options) unless resize_to image = MiddlemanSimpleThumbnailer::Image.new(path, self.config) image.resize!(resize_to) if environment == :development super("data:#{image.mime_type};base64,#{image.base64_data}", options) else super(image.resized_img_path, options) end end end end end ::Middleman::Extensions.register(:middleman_simple_thumbnailer, MiddlemanSimpleThumbnailer::Extension)
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
middleman-simple-thumbnailer-0.0.7 | lib/middleman-simple-thumbnailer/extension.rb |