Sha256: 0e114eb30e0505750688654e3fb3ad360fc8ab6dda328d97234948d2e25c7623

Contents?: true

Size: 717 Bytes

Versions: 2

Compression:

Stored size: 717 Bytes

Contents

module Jekyll
  module ImageResizer
    class Thumbnail < Resizer
      attr_accessor :thumbnail_width

      def initialize(args, options)
        super
        @thumbnail_width = options['thumbnail_width']
      end

      def process_image(image_name, image_path)
        image = resize_image(image_path) do |image, ratio|
          height = if image.width > image.height
                     thumbnail_width / ratio
                   else
                     thumbnail_width * ratio
                   end.round

          [thumbnail_width, height]
        end

        thumbnail_image_name = image_name.prepend('thumbnail-')
        image.write("#{folder}/#{thumbnail_image_name}")
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
jekyll-image-resizer-0.7.1 lib/jekyll-image-resizer/thumbnail.rb
jekyll-image-resizer-0.7.0 lib/jekyll-image-resizer/thumbnail.rb