1
0
mirror of https://github.com/danbee/danbarberphoto synced 2025-03-04 08:49:07 +00:00

Restore fetching of attributes from EXIF

This commit is contained in:
Daniel Barber 2015-10-15 17:41:42 +01:00
parent 0fb938aa26
commit fb0fcdb120

View File

@ -8,9 +8,10 @@ class Photo < ActiveRecord::Base
self.per_page = 11 self.per_page = 11
scope :enabled, -> { where(enabled: true) } scope :enabled, -> { where(enabled: true) }
scope :featured, -> { enabled.where(featured: true) } scope :featured, -> { enabled.where(featured: true) }
after_create :process_exif
def to_s def to_s
title title
end end
@ -27,4 +28,17 @@ class Photo < ActiveRecord::Base
end end
save save
end end
private
def process_exif
self.title = exif.title if title.empty?
self.description = exif.description if description.empty?
self.taken_at = exif.date_time_original
save
end
def exif
@exif ||= MiniExiftool.new(image.file.path)
end
end end