Sha256: 99717a6ae6705bd38e2e38a84e7f502cc277ed39f61f1de13e86a7dd972983c4
Contents?: true
Size: 1.13 KB
Versions: 6
Compression:
Stored size: 1.13 KB
Contents
module Middleman module AutomaticClowncar class ThumbnailResource < ::Middleman::Sitemap::Resource require 'mini_magick' attr_accessor :output def initialize(store, path, dimensions, origin, root_path, build_dir, source_dir) @dimensions = dimensions @origin = origin @root_path = root_path @build_dir = build_dir @source_dir = source_dir super(store, path, source_dir.to_s) end def template? false end def source_file nil end def render(*args, &block) output_dir = File.join(@root_path,@build_dir) dest_path = File.join(output_dir,@path) img = nil if Utils.timestamp_current?(@source_dir,@build_dir,@origin) && File.exist?(dest_path) img = MiniMagick::Image.open(dest_path) else img = MiniMagick::Image.open(@origin) img.resize(@dimensions) unless @dimensions.blank? end img.to_blob end def binary? false end def raw_data {} end def ignored? false end end end end
Version data entries
6 entries across 6 versions & 1 rubygems