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:
parent
0fb938aa26
commit
fb0fcdb120
@ -8,9 +8,10 @@ class Photo < ActiveRecord::Base
|
||||
self.per_page = 11
|
||||
|
||||
scope :enabled, -> { where(enabled: true) }
|
||||
|
||||
scope :featured, -> { enabled.where(featured: true) }
|
||||
|
||||
after_create :process_exif
|
||||
|
||||
def to_s
|
||||
title
|
||||
end
|
||||
@ -27,4 +28,17 @@ class Photo < ActiveRecord::Base
|
||||
end
|
||||
save
|
||||
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
|
||||
|
||||
Loading…
Reference in New Issue
Block a user