Sha256: e5bcbb08bfc790947e9cfdad1bd43f823946c30a99a3b021ce548a0b79190f05
Contents?: true
Size: 1.43 KB
Versions: 73
Compression:
Stored size: 1.43 KB
Contents
namespace :images do desc "Regenerate all thumbnails. Useful for when you've changed size or cropping on the images after images have been uploaded." task :regenerate => :environment do thumbnails_size = Image.count(:conditions => "parent_id IS NOT NULL") puts "Preparing to delete #{thumbnails_size} generated thumbnails" if Image.destroy_all("parent_id IS NOT null") puts "--> #{thumbnails_size} thumbnails deleted" else puts "There may have been a problem deleting the thumbnails." end originals = Image.originals puts "Preparing to regenerate thumbnails for #{originals.size} images" originals.each do |image| begin image.save rescue Exception => e puts "--> ERROR image #{image.id} could not be saved because #{e.message}" end end puts "Image regeneration complete." end desc "Update thumbnails. Useful for when you have added new thumbnail sizes and you just need to regenerate those without regenerating all the thumbnails again." task :update => :environment do originals = Image.originals puts "Preparing to update #{originals.size} images. This may take a few minutes. Please wait..." originals.each do |image| begin image.save rescue Exception => e puts "--> ERROR image #{image.id} could not be saved because #{e.message}" end end puts "Thumbnail update complete." end end
Version data entries
73 entries across 73 versions & 2 rubygems