Rails update. Fancybox update. Migrations from Paperclip.

This commit is contained in:
Christoph Haas 2020-10-19 18:49:15 +02:00
parent 1d97215591
commit 7ac69a1d8a
25 changed files with 305 additions and 115 deletions

View file

@ -10,15 +10,15 @@ class Screenshot < ApplicationRecord
validates :image, attached: true, content_type: { in: 'image/png', message: 'is not a valid PNG image file' }
# Before migration from Paperclip to ActiveStorage:
#has_attached_file :image,
# styles: { :large => '800x600>', :thumb => '160x120>' },
# default_url: '/images/dummy/no-screenshots-available.svg',
# path: ':rails_root/public/screenshots/:id_partition/:style.png',
# url: '/screenshots/:id_partition/:style.png'
#validates_attachment_content_type :image, :content_type => 'image/png'
#validates_with AttachmentSizeValidator, :attributes => :image, :less_than => 5.megabytes
# validate :validate_image_is_unique
validates :delete_reason, length: { in: 5..100 }, allow_nil: true
# has_attached_file :image,
# styles: { :large => '800x600>', :thumb => '160x120>' },
# default_url: '/images/dummy/no-screenshots-available.svg',
# path: ':rails_root/public/screenshots/:id_partition/:style.png',
# url: '/screenshots/:id_partition/:style.png'
# validates_attachment_content_type :image, :content_type => 'image/png'
# validates_with AttachmentSizeValidator, :attributes => :image, :less_than => 5.megabytes
# # validate :validate_image_is_unique
# validates :delete_reason, length: { in: 5..100 }, allow_nil: true
# Validator that checks if the image has already been uploaded.
# A generic uniqueness validator does not work because it would attribute
@ -163,4 +163,12 @@ class Screenshot < ApplicationRecord
#Digest::MD5.base64digest(Net::HTTP.get(URI(url)))
end
def large_watermarked
if self.image.attached?
self.image.variant(combine_options: {
gravity: 'SouthEast',
draw: 'image Over 0,0 0,0 "public/logo/watermark.png"'
}).processed
end
end
end