Dont Convert when initialized by import
This commit is contained in:
parent
492ac74819
commit
f995e6af0d
3 changed files with 3 additions and 2 deletions
|
|
@ -38,6 +38,7 @@ class Photo < ApplicationRecord
|
|||
|
||||
mount_uploader :processed_image, ProcessedImage
|
||||
mount_uploader :unprocessed_image, UnprocessedImage
|
||||
attr_accessor :keep_original_format
|
||||
|
||||
belongs_to :status_message, foreign_key: :status_message_guid, primary_key: :guid, optional: true
|
||||
validates_associated :status_message
|
||||
|
|
@ -50,7 +51,6 @@ class Photo < ApplicationRecord
|
|||
|
||||
after_commit on: :create do
|
||||
queue_processing_job if author.local?
|
||||
|
||||
end
|
||||
|
||||
scope :on_statuses, ->(post_guids) {
|
||||
|
|
|
|||
|
|
@ -74,6 +74,7 @@ class ImportService
|
|||
def store_and_process_photo(photo, uploaded_file, random_string)
|
||||
File.open(uploaded_file) do |file|
|
||||
photo.random_string = random_string
|
||||
photo.keep_original_format = true
|
||||
photo.unprocessed_image.store! file
|
||||
photo.update_remote_path
|
||||
photo.save(touch: false)
|
||||
|
|
|
|||
|
|
@ -31,7 +31,7 @@ class UnprocessedImage < CarrierWave::Uploader::Base
|
|||
|
||||
def needs_converting?
|
||||
extname = File.extname(@filename)
|
||||
%w[.webp .gif].exclude?(extname)
|
||||
%w[.webp .gif].exclude?(extname) && !model.keep_original_format
|
||||
end
|
||||
|
||||
process :basic_process
|
||||
|
|
|
|||
Loading…
Reference in a new issue