Class: Mill::Resource::Image
- Inherits:
-
Mill::Resource
- Object
- Mill::Resource
- Mill::Resource::Image
- Includes:
- HTMLHelpers
- Defined in:
- lib/mill/resources/image.rb
Constant Summary collapse
- FileTypes =
%w{ image/gif image/jpeg image/png image/tiff image/vnd.microsoft.icon image/x-icon image/svg image/svg+xml }
Constants included from HTMLHelpers
HTMLHelpers::LinkElementsXPath
Instance Attribute Summary collapse
-
#height ⇒ Object
Returns the value of attribute height.
-
#width ⇒ Object
Returns the value of attribute width.
Attributes inherited from Mill::Resource
#content, #date, #input_file, #output_file, #public, #site, #type
Instance Method Summary collapse
Methods included from HTMLHelpers
#check_errors, #find_link_elements, #google_analytics, #html_document, #html_fragment, #link_if, #parse_html, #parse_html_fragment, #replace_element
Methods inherited from Mill::Resource
#absolute_uri, #build, #change_frequency, #final_content, #find_sibling_resources, #initialize, #parent_uri, #public?, #save, #tag_uri, #uri
Constructor Details
This class inherits a constructor from Mill::Resource
Instance Attribute Details
#height ⇒ Object
Returns the value of attribute height.
21 22 23 |
# File 'lib/mill/resources/image.rb', line 21 def height @height end |
#width ⇒ Object
Returns the value of attribute width.
20 21 22 |
# File 'lib/mill/resources/image.rb', line 20 def width @width end |
Instance Method Details
#img_html ⇒ Object
36 37 38 39 40 41 42 43 44 |
# File 'lib/mill/resources/image.rb', line 36 def img_html html_fragment do |html| html.img( src: uri, alt: @title, height: @height, width: @width) end end |
#inspect ⇒ Object
23 24 25 26 27 28 |
# File 'lib/mill/resources/image.rb', line 23 def inspect super + ", width: %p, height: %p" % [ @width, @height, ] end |
#load ⇒ Object
30 31 32 33 34 |
# File 'lib/mill/resources/image.rb', line 30 def load info = ImageSize.path(@input_file.to_s) @width, @height = *info.size super end |