Guest User

Untitled

a guest
May 16th, 2018
148
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.57 KB | None | 0 0
  1. ## photo_meta.rb
  2.  
  3. module PhotoMeta
  4. def self.new(data)
  5. return YAML.load(data)
  6. end
  7. end
  8.  
  9. ## photo.rb
  10.  
  11. class Photo < ActiveRecord::Base
  12. has_attachment :storage => :file_system
  13.  
  14. composed_of :meta, :class_name => 'PhotoMeta', :mapping => [%w(meta_data to_yaml)]
  15.  
  16. after_resize do |record,img|
  17. if record.meta_data.blank?
  18. record.meta = MiniExiftool.new(record.temp_path, :composite => true)
  19. record.caption = record.meta.headline
  20. record.description = record.meta.description
  21. record.tag_list = record.meta.keywords
  22. end
  23. end
  24. end
Add Comment
Please, Sign In to add comment