Class: Slickr::Image

Inherits:
ApplicationRecord show all
Defined in:
app/models/slickr/image.rb

Instance Method Summary collapse

Instance Method Details

#admin_batch_delete_pathObject



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_pathObject



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_pathObject



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


7
8
9
10
# File 'app/models/slickr/image.rb', line 7

def build_for_gallery
  extension = File.extname(attachment.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(attachment.current_path)
  cropped_image = image.crop(x, y, w, h)
  cropped_image.write(attachment.current_path)
  attachment.recreate_versions!
end

#timestamped_image_urlObject



24
25
26
# File 'app/models/slickr/image.rb', line 24

def timestamped_image_url
  "#{attachment.url}?timestamp=#{DateTime.now.to_s}"
end