Howto: rebuild thumbnails in attachment_fu

36 views
Skip to first unread message

Russell Fine

unread,
Nov 9, 2009, 11:26:49 AM11/9/09
to rubyonra...@googlegroups.com
I've just added a new thumbnail definition to a class that has
attachments using attachment_fu. Since this thumbnail definition didn't
exist when I uploaded pior images, they don't have this thumbnail. I
have been trying to figure out how to either load the image attachment
and have it build the thumbnail. Does anyone know how to do this?

Thanks in advance.

Russell
--
Posted via http://www.ruby-forum.com/.

Walter McGinnis

unread,
Nov 9, 2009, 8:04:22 PM11/9/09
to rubyonra...@googlegroups.com
Here's some example code from the Kete project (http://kete.net.nz):

http://github.com/kete/kete/blob/master/lib/tasks/tools.rake -
starting at line 61

Cheers,
Walter

foz

unread,
Nov 29, 2009, 11:06:41 PM11/29/09
to Ruby on Rails: Talk
I ran across this post while looking for a solution to the same
problem. In the end, this worked for me in the attachment model class:

# use attachment_fu protected methods to remake thumbs
def remake_thumbnails!
self.thumbnails.each {|thumb| thumb.destroy}
temp_file = create_temp_file
attachment_options[:thumbnails].each do |suffix, size|
self.create_or_update_thumbnail(temp_file, suffix, *size)
end
end

I use this in a rake task so I can rebuild all thumbnails when needed.

cheers,
-foz

On Nov 9, 5:26 pm, Russell Fine <rails-mailing-l...@andreas-s.net>
wrote:
Reply all
Reply to author
Forward
0 new messages