Sha256: 843a3222536738cb8dd1b3900c3e86e8c597d8b7c93c3f8c5337c235ffa84cb1
Contents?: true
Size: 914 Bytes
Versions: 3
Compression:
Stored size: 914 Bytes
Contents
module ImageHelper def display_image(object, photo_association_name=:photo, width=80) if width.is_a?(String) if width.include?("px") width_val = width.split("px").first elsif width.include?("%") width_val = width.split("%").first else width_val = width.to_i end width_string = width else width_val = width width_string = "#{width.to_i}px" end if object.respond_to?(photo_association_name) && object.send(photo_association_name) return image_tag object.send(photo_association_name).image_url, :style=>"width:#{width_string};" else return image_tag "http://placehold.it/#{width_val}x#{width_val}", :class=>"img-thumbnail" end end def display_photo(photo, width=100) return image_tag photo.image_url, :style=>"width:#{width}px;", :width=>"#{width}", :class=>"img-thumbnail" end end
Version data entries
3 entries across 3 versions & 1 rubygems