Class: Mill::Resource::Image

Inherits:
Mill::Resource show all
Includes:
HTMLHelpers
Defined in:
lib/mill/resources/image.rb

Constant Summary

Constants included from HTMLHelpers

HTMLHelpers::IgnoreErrors

Instance Attribute Summary collapse

Attributes inherited from Mill::Resource

#content, #date, #input_file, #mill, #output_file, #public

Class Method Summary collapse

Instance Method Summary collapse

Methods included from HTMLHelpers

#amazon_button, #google_analytics, #html_document, #html_fragment, #parse_html, #parse_tidy_errors, #paypal_button, #replace_element, #tidy_html

Methods inherited from Mill::Resource

#absolute_uri, #build, #change_frequency, #final_content, #initialize, #tag_uri, #uri, #validate, #validate_xml

Constructor Details

This class inherits a constructor from Mill::Resource

Instance Attribute Details

#heightObject

Returns the value of attribute height.



10
11
12
# File 'lib/mill/resources/image.rb', line 10

def height
  @height
end

#widthObject

Returns the value of attribute width.



9
10
11
# File 'lib/mill/resources/image.rb', line 9

def width
  @width
end

Class Method Details

.typeObject



12
13
14
# File 'lib/mill/resources/image.rb', line 12

def self.type
  :image
end

Instance Method Details

#img_htmlObject



22
23
24
25
26
27
28
29
30
# File 'lib/mill/resources/image.rb', line 22

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

#loadObject



16
17
18
19
20
# File 'lib/mill/resources/image.rb', line 16

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