diff options
| author | erdgeist <erdgeist@erdgeist.org> | 2026-07-21 21:02:16 +0200 |
|---|---|---|
| committer | erdgeist <erdgeist@erdgeist.org> | 2026-07-21 21:02:16 +0200 |
| commit | 5b951f012e04e6ef97e4ef645d53bdf433a9eb7f (patch) | |
| tree | 207addbdbb48df480f491d2b4b860c18171b3549 /lib/tasks/assets.rake | |
| parent | 1791d8067d00dc1381b9cdc3cc4ad44c1f6c7197 (diff) | |
Implement model side of PDF raster preview generation
Diffstat (limited to 'lib/tasks/assets.rake')
| -rw-r--r-- | lib/tasks/assets.rake | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/lib/tasks/assets.rake b/lib/tasks/assets.rake index 9d4b048..e778021 100644 --- a/lib/tasks/assets.rake +++ b/lib/tasks/assets.rake | |||
| @@ -1,7 +1,9 @@ | |||
| 1 | namespace :assets do | 1 | namespace :assets do |
| 2 | desc "Regenerate ImageMagick variants for every image asset from its stored original -- rerun whenever a new style is added to FileAttachment::STYLES after assets already exist. Scope to one asset first with ASSET_ID=123." | 2 | desc "Regenerate ImageMagick variants for every image asset from its stored original -- rerun whenever a new style is added to FileAttachment::STYLES after assets already exist. Scope to one asset first with ASSET_ID=123." |
| 3 | task :regenerate_variants => :environment do | 3 | task :regenerate_variants => :environment do |
| 4 | scope = Asset.images | 4 | scope = Asset.where(upload_content_type: FileAttachment::IMAGE_CONTENT_TYPES + |
| 5 | FileAttachment::VECTOR_CONTENT_TYPES + | ||
| 6 | FileAttachment::RASTERIZED_CONTENT_TYPES) | ||
| 5 | scope = scope.where(id: ENV["ASSET_ID"]) if ENV["ASSET_ID"].present? | 7 | scope = scope.where(id: ENV["ASSET_ID"]) if ENV["ASSET_ID"].present? |
| 6 | 8 | ||
| 7 | scope.find_each do |asset| | 9 | scope.find_each do |asset| |
| @@ -12,7 +14,7 @@ namespace :assets do | |||
| 12 | next | 14 | next |
| 13 | end | 15 | end |
| 14 | 16 | ||
| 15 | asset.send(:generate_variants, original_path) | 17 | asset.send(:generate_all_variants, original_path) |
| 16 | puts "Regenerated variants for Asset##{asset.id} (#{asset.name})" | 18 | puts "Regenerated variants for Asset##{asset.id} (#{asset.name})" |
| 17 | end | 19 | end |
| 18 | end | 20 | end |
