OSDN Git Service

t#29312:any update
[pettanr/pettanr.git] / app / models / resource_picture.rb
index 5e1b4f7..9c1514f 100644 (file)
@@ -78,9 +78,14 @@ class ResourcePicture < ActiveRecord::Base
     ResourcePicture.resize(rimg.to_blob, tw, th).to_blob
   end
   
+  def opt_img_tag
+    tw, th = ResourcePicture.fix_size_both(MagicNumber['thumbnail_width'], MagicNumber['thumbnail_height'], self.width, self.height)
+    {:src => self.url, :width => tw, :height => th}
+  end
+  
   def copy_data(op)
     attr = {:width => op.width, :height => op.height, :ext => op.ext, :filesize => op.filesize, 
-      :original_picture_id => op.id, :artist_id => op.artist_id
+      :original_picture_id => op.id, :artist_id => op.artist_id, :md5 => op.md5
     }
     self.attributes = attr
   end