summaryrefslogtreecommitdiff
path: root/lib/tasks
diff options
context:
space:
mode:
authorerdgeist <erdgeist@erdgeist.org>2026-07-30 04:40:08 +0200
committererdgeist <erdgeist@erdgeist.org>2026-07-30 04:40:08 +0200
commit6c62d0c538e6b8baa416a7ed901a74a66de44348 (patch)
tree8898d14562a8c8b2e7e3a10a9a43d0018372a6f9 /lib/tasks
parent02250d025043f9953923a7be09605830d554db10 (diff)
Generate a 1200x630 social card variant for every asset
Diffstat (limited to 'lib/tasks')
-rw-r--r--lib/tasks/assets.rake13
1 files changed, 11 insertions, 2 deletions
diff --git a/lib/tasks/assets.rake b/lib/tasks/assets.rake
index e778021e..078d3c63 100644
--- a/lib/tasks/assets.rake
+++ b/lib/tasks/assets.rake
@@ -6,6 +6,7 @@ namespace :assets do
6 FileAttachment::RASTERIZED_CONTENT_TYPES) 6 FileAttachment::RASTERIZED_CONTENT_TYPES)
7 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?
8 8
9 skipped = []
9 scope.find_each do |asset| 10 scope.find_each do |asset|
10 original_path = asset.send(:file_path, :original) 11 original_path = asset.send(:file_path, :original)
11 12
@@ -14,8 +15,16 @@ namespace :assets do
14 next 15 next
15 end 16 end
16 17
17 asset.send(:generate_all_variants, original_path) 18 if asset.send(:generate_all_variants, original_path)
18 puts "Regenerated variants for Asset##{asset.id} (#{asset.name})" 19 puts "Regenerated variants for Asset##{asset.id} (#{asset.name})"
20 else
21 skipped << asset.id
22 puts "Skipped Asset##{asset.id} (#{asset.name}) -- source has no rasterisable page"
23 end
24 end
25
26 if skipped.any?
27 puts "\n#{skipped.size} asset(s) skipped, no variants written: #{skipped.join(", ")}"
19 end 28 end
20 end 29 end
21 30