foto exif

This commit is contained in:
Andreas Stephanides
2015-04-07 23:19:27 +02:00
parent bd7aac9bb7
commit b04b23e647
4 changed files with 27 additions and 1 deletions

View File

@@ -15,6 +15,7 @@ class Foto < ActiveRecord::Base
attr_accessible :datei, :desc, :gallery_id, :title
belongs_to :gallery
mount_uploader :datei, FotoUploader
before_save :parse_exif
resourcify
def to_jq_upload
{
@@ -28,4 +29,11 @@ class Foto < ActiveRecord::Base
"delete_type" => "DELETE"
}
end
def parse_exif
unless self.exif.nil? || self.exif.empty?
j=JSON.parse(self.exif)
datetime = j.select {|i| i.first == "DateTime"}.try(:first).try(:last)
self.taken_at=Time.new(datetime) unless datetime.nil?
end
end
end