This commit is contained in:
Nicolas Bally 2018-06-11 02:17:25 +02:00
parent b8e35b533c
commit c8bce92e3e
2 changed files with 0 additions and 84 deletions

View File

@ -10,9 +10,6 @@ class DataFile < ActiveRecord::Base
belongs_to :data_file_category belongs_to :data_file_category
has_many :animal_animalables, :as => :animalable
has_many :animals, :through => :animal_animalables
has_many :category_categoryables, :as => :categoryable has_many :category_categoryables, :as => :categoryable
has_many :categories, :through => :category_categoryables has_many :categories, :through => :category_categoryables
@ -63,11 +60,6 @@ class DataFile < ActiveRecord::Base
{ {
title: title, title: title,
description: long_desc, description: long_desc,
category_names: categories.map(&:name),
category_ids: categories.map(&:id),
animals_names: animals.map(&:name),
animals_ids: animals.map(&:id),
document: (data_file_category ? data_file_category.name.to_slug : "document"),
created_at: created_at created_at: created_at
} }
end end

View File

@ -63,83 +63,7 @@ class ImageUploader < CarrierWave::Uploader::Base
process :resize_to_fill => [250, 250] process :resize_to_fill => [250, 250]
end end
version :secure do
process :resize_to_limit => [1000, 800]
#process :convert => 'png'
process :watermark
def store_dir
"public_medias/secure/#{model.id}"
end
def filename
"#{model.token_s}.#{file.extension}"# if original_filename.present?
end
def full_filename (for_file = model.file.file)
"secure_#{model.token_s}"+File.extname(for_file).to_s
end
end
version :secure_thumb do
process :resize_to_fit => [250, 300]
def store_dir
"public_medias/secure/#{model.id}"
end
def filename
"#{model.token_s}.#{file.extension}" if original_filename.present?
end
def full_filename (for_file = model.file.file)
"secure_thumb_#{model.token_s}"+File.extname(for_file).to_s
end
end
version :square_secure_thumb do
process :resize_to_fill => [250, 250]
def store_dir
"public_medias/secure/#{model.id}"
end
def filename
"#{model.token_s}.#{file.extension}" if original_filename.present?
end
def full_filename (for_file = model.file.file)
"square_secure_thumb_#{model.token_s}"+File.extname(for_file).to_s
end
end
def watermark
manipulate! do |img|
logo = Magick::Image.read("#{Rails.root}/watermark.png").first
puts img.rows
puts img.columns
#watermark = logo.resize_to_fit(img.columns * 0.4, img.rows * 0.25)
if img.columns >= 1000 or img.rows >= 800
watermark = logo.resize_to_fit(220, 220)
else
watermark = logo.resize_to_fit(img.columns * 0.4, img.rows * 0.25)
end
#img = img.composite(watermark, Magick::SouthEastGravity, (watermark.columns*-0.4), 10, Magick::OverCompositeOp)
img = img.composite(watermark, Magick::SouthWestGravity,Magick::OverCompositeOp)
#img = img.dissolve(watermark, 0.4, 1, Magick::CenterGravity)
#img = img.watermark(watermark, 0.1,0.1, Magick::CenterGravity)
end
end
# Add a white list of extensions which are allowed to be uploaded. # Add a white list of extensions which are allowed to be uploaded.