Sha256: abb2d3e7aa7872356d1414eb9c484ac3ee5ff49b4fc63275002d6f4b3333e687
Contents?: true
Size: 1.3 KB
Versions: 1
Compression:
Stored size: 1.3 KB
Contents
module Artwork module View def activate_resolution_independence content_tag :script do Thread.current[:artwork_script] ||= begin artwork_script_path = Artwork.root_path + '/assets/javascripts/artwork.js' Uglifier.compile(File.read(artwork_script_path)).html_safe end end end def artwork_tag(record, attachment_name, size, options = {}) image_tag_options = options[:image] || {} img_holder_options = options[:img_holder] || {} image_tag_options[:alt] ||= extract_title_from(record) image_url = record.artwork_url attachment_name, size, options if options[:auto_height] image = record.send(attachment_name) if image.height.present? and image.width.present? padding = ((image.height.to_f / image.width) * 100).round(4) img_holder_options[:style] = "padding-bottom:#{padding}%;" end end content_tag :div, :class => attachment_name do content_tag :div, img_holder_options.merge(:class => 'img-holder') do image_tag image_url, image_tag_options end end end private def extract_title_from(record) if record.respond_to? :title record.title elsif record.respond_to? :name record.name end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
artwork-0.2.0 | lib/artwork/view.rb |