page_attachmentエクステンションを利用すると、Wikiの様にページごとに画像を添付することができる。でも、リサイズをしてくれなかったりするのでその辺を改良。このextensiongがRailsのプラグインであるattachment_fuを利用していたので簡単に改良できた。
hoge@hoge-laptop:~/work/radiant/vendor/extensions/page_attachments$ svn diff Index: app/models/page_attachment.rb =================================================================== --- app/models/page_attachment.rb (リビジョン 881) +++ app/models/page_attachment.rb (作業コピー) @@ -1,7 +1,8 @@ class PageAttachment < ActiveRecord::Base has_attachment :storage => :file_system, - :thumbnails => {:icon => '50x50>'}, + :thumbnails => {:medium => '600x450>', :icon => '50x50>' }, :max_size => 10.megabytes + validates_as_attachment belongs_to :created_by, :class_name => 'User', @@ -10,4 +11,4 @@ :foreign_key => 'updated_by' belongs_to :page -end \ No newline at end of file +end Index: app/views/admin/page/_attachment.html.erb =================================================================== --- app/views/admin/page/_attachment.html.erb (リビジョン 881) +++ app/views/admin/page/_attachment.html.erb (作業コピー) @@ -2,7 +2,15 @@ <% unless attachment.thumbnails.empty? %> <%= link_to image_tag(attachment.thumbnails.first.public_filename), attachment.public_filename, :class => 'thumbnail' %> + (<a href="javascript:alert('<%= attachment.public_filename %>');">original size</a>) + + + <% if attachment.thumbnails[1] %> + <%= link_to image_tag(attachment.thumbnails.first.public_filename), + attachment.thumbnails[1].public_filename, :class => 'thumbnail' %> + (<a href="javascript:alert('<%= attachment.thumbnails[1].public_filename %>')">middle size</a>) + <% end %> + <% end %> - <%= link_to File.basename(attachment.public_filename), attachment.public_filename %> <%= image_tag "admin/minus.png", :alt => "Delete", :class => 'delete' %> </li>