Skip to content

Commit

Permalink
Merge pull request #99 from insales/EC-5430_fix_image_sizes
Browse files Browse the repository at this point in the history
После постобработки оригинала обновляем размер файла и размерность изображения
  • Loading branch information
hbda authored Oct 28, 2024
2 parents f464d9b + 81810d8 commit 73be687
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions lib/paperclip/attachment.rb
Original file line number Diff line number Diff line change
Expand Up @@ -155,12 +155,22 @@ def assign uploaded_file

@dirty = true

post_process if post_processing && valid?
if post_processing && valid?
post_process

# Reset the file size and image sizes if the original file was reprocessed.
if queued_for_write.dig(:original) && instance_read(:file_size) != queued_for_write[:original].size.to_i
instance_write(:file_size, queued_for_write[:original].size.to_i)
sizes = FastImage.size(queued_for_write[:original])
if sizes && sizes[0] && sizes[1]
instance_write(:width, sizes[0])
instance_write(:height, sizes[1])
end
end
end

updater = :"#{name}_file_name_will_change!"
instance.send updater if instance.respond_to? updater
# Reset the file size if the original file was reprocessed.
instance_write(:file_size, queued_for_write[:original].size.to_i)
ensure
uploaded_file.close if close_uploaded_file
validate
Expand Down

0 comments on commit 73be687

Please sign in to comment.