Module: ActionView::Helpers::InstanceTagMethods
- Defined in:
- lib/simple_crop/action_view_extensions/instance_tag.rb
Instance Method Summary collapse
- #crop_ratio(paperclip, select_style) ⇒ Object
- #paperclip_geometry(paperclip, style) ⇒ Object
- #to_simple_crop_preview_tag(options) ⇒ Object
- #to_simple_crop_tag(options) ⇒ Object
Instance Method Details
#crop_ratio(paperclip, select_style) ⇒ Object
16 17 18 19 20 |
# File 'lib/simple_crop/action_view_extensions/instance_tag.rb', line 16 def crop_ratio paperclip, select_style original_geometry = paperclip_geometry(paperclip, :original) select_geometry = paperclip_geometry(paperclip, select_style) "#{original_geometry.width.to_i.to_s}/#{select_geometry.width.to_i.to_s}" end |
#paperclip_geometry(paperclip, style) ⇒ Object
22 23 24 |
# File 'lib/simple_crop/action_view_extensions/instance_tag.rb', line 22 def paperclip_geometry(paperclip, style) Paperclip::Geometry.from_file paperclip.to_file(style) end |
#to_simple_crop_preview_tag(options) ⇒ Object
4 5 6 7 8 9 |
# File 'lib/simple_crop/action_view_extensions/instance_tag.rb', line 4 def to_simple_crop_preview_tag() paperclip = ["object"].send(@method_name) target_crop_geometry = paperclip_geometry(paperclip, ["crop"]) div_style = "padding:0;overflow:hidden;width:#{target_crop_geometry.width.to_i.to_s}px;height:#{target_crop_geometry.height.to_i.to_s}px;" content_tag("div", tag("img",{:src => paperclip.url(["select"])}), {:class => "simple-crop-preview", :id => "#{sanitized_object_name}_simple_crop_preview", :style => div_style}) end |
#to_simple_crop_tag(options) ⇒ Object
11 12 13 14 |
# File 'lib/simple_crop/action_view_extensions/instance_tag.rb', line 11 def to_simple_crop_tag() paperclip = ["object"].send(@method_name) tag("img",{:src => paperclip.url(["select"]), :"data-crop-ratio" => crop_ratio(paperclip, ["select"]), :"data-crop-for" => sanitized_object_name}) end |