Class: Yuzu::PostProcessors::Thumbnails
- Defined in:
- lib/yuzu/postprocessors/thumbnails.rb
Instance Method Summary collapse
-
#initialize(images, thumbnail_sizes) ⇒ Thumbnails
constructor
A new instance of Thumbnails.
Constructor Details
#initialize(images, thumbnail_sizes) ⇒ Thumbnails
Returns a new instance of Thumbnails.
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/yuzu/postprocessors/thumbnails.rb', line 20 def initialize(images, thumbnail_sizes) image_path = images.empty? ? nil : images[0] (class << self; self; end).class_eval do thumbnail_sizes.each do |size| define_method size do begin if image_path.nil? "" else ext = File.extname(image_path) new_name = image_path.sub(ext, "-#{size}#{ext}") Html::Image.new(:src => new_name).to_s end rescue => e puts "Exception in thumbnails" puts e. end end end end end |