Skip to content

Commit

Permalink
Size tweak, task (+ Capistrano) to reprocess all photos
Browse files Browse the repository at this point in the history
[skip ci]
  • Loading branch information
janosrusiczki committed Aug 27, 2019
1 parent cbca6d4 commit d0acea7
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 1 deletion.
3 changes: 2 additions & 1 deletion app/uploaders/image_uploader.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ class ImageUploader < Shrine
versions = { original: io }
io.download do |original|
pipeline = ImageProcessing::MiniMagick.source(original)
versions[:large] = pipeline.resize_to_limit!(1920, 1920)
versions[:extralarge] = pipeline.resize_to_limit!(1920, 1920)
versions[:large] = pipeline.resize_to_limit!(1200, 1200)
versions[:medium] = pipeline.resize_to_limit!(600, 600)
versions[:thumbnail] = pipeline.resize_to_fill!(150, 150)
end
Expand Down
13 changes: 13 additions & 0 deletions lib/capistrano/tasks/photos.rake
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# frozen_string_literal: true

namespace :photos do
task :reprocess do
on roles(:app) do
within current_path.to_s do
with rails_env: fetch(:stage).to_s do
execute :rake, 'photos:reprocess'
end
end
end
end
end
10 changes: 10 additions & 0 deletions lib/tasks/photos.rake
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# frozen_string_literal: true

namespace :photos do
desc 'Reprocess all photos'
task reprocess: :environment do
Photo.find_each do |photo|
photo.update(image: photo.image[:original])
end
end
end

0 comments on commit d0acea7

Please sign in to comment.