Sha256: 6d7d5c300f04cf37f74825a25523f5a68917ee5868c2b0855461f9ad470f599e

Contents?: true

Size: 765 Bytes

Versions: 9

Compression:

Stored size: 765 Bytes

Contents

module Mill

  class Resource

    class Image < Resource

      include HTMLHelpers

      FileTypes = %w{
        image/gif
        image/jpeg
        image/png
        image/tiff
        image/vnd.microsoft.icon
        image/svg+xml
      }

      attr_accessor :width
      attr_accessor :height

      def inspect
        super + ", width: %p, height: %p" % [
          @width,
          @height,
        ]
      end

      def load
        info = ImageSize.path(@input_file.to_s)
        @width, @height = *info.size
        super
      end

      def img_html
        html_fragment do |html|
          html.img(
            src: uri,
            alt: @title,
            height: @height,
            width: @width)
        end
      end

    end

  end

end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
mill-0.16 lib/mill/resources/image.rb
mill-0.11 lib/mill/resources/image.rb
mill-0.10 lib/mill/resources/image.rb
mill-0.9.1 lib/mill/resources/image.rb
mill-0.9 lib/mill/resources/image.rb
mill-0.8.4 lib/mill/resources/image.rb
mill-0.8.3 lib/mill/resources/image.rb
mill-0.8.2 lib/mill/resources/image.rb
mill-0.8 lib/mill/resources/image.rb