Class: Slickr::Image
- Inherits:
-
ApplicationRecord
- Object
- ActiveRecord::Base
- ApplicationRecord
- Slickr::Image
- Defined in:
- app/models/slickr/image.rb
Instance Method Summary collapse
- #admin_batch_delete_path ⇒ Object
- #admin_edit_path ⇒ Object
- #admin_update_path ⇒ Object
- #build_for_gallery ⇒ Object
- #crop(x, y, w, h) ⇒ Object
- #timestamped_image_url ⇒ Object
Instance Method Details
#admin_batch_delete_path ⇒ Object
20 21 22 |
# File 'app/models/slickr/image.rb', line 20 def admin_batch_delete_path Rails.application.routes.url_helpers.batch_action_admin_slickr_images_path end |
#admin_edit_path ⇒ Object
12 13 14 |
# File 'app/models/slickr/image.rb', line 12 def admin_edit_path Rails.application.routes.url_helpers.edit_admin_slickr_image_path(id) end |
#admin_update_path ⇒ Object
16 17 18 |
# File 'app/models/slickr/image.rb', line 16 def admin_update_path Rails.application.routes.url_helpers.admin_slickr_image_path(id) end |
#build_for_gallery ⇒ Object
7 8 9 10 |
# File 'app/models/slickr/image.rb', line 7 def build_for_gallery extension = File.extname(.file.filename) extension == '.pdf' ? build_pdf : build_image end |
#crop(x, y, w, h) ⇒ Object
28 29 30 31 32 33 34 |
# File 'app/models/slickr/image.rb', line 28 def crop(x, y, w, h) return if (x || y || w || h) == nil image = Magick::ImageList.new(.current_path) cropped_image = image.crop(x, y, w, h) cropped_image.write(.current_path) .recreate_versions! end |
#timestamped_image_url ⇒ Object
24 25 26 |
# File 'app/models/slickr/image.rb', line 24 def "#{.url}?timestamp=#{DateTime.now.to_s}" end |