Opened 12 years ago

Closed 11 years ago

Last modified 11 years ago

#532 closed enhancement (fixed)

Show creation date (extract from EXIF)

Reported by: tryggvib Owned by:
Priority: minor Milestone: 0.4.0
Component: programming Keywords: exif, DateTimeOriginal, review
Cc: Elrond Parent Tickets:


Short description

Add an option to make the creation date (as defined in the EXIF information) of a media object visible, e.g. to show when a photo was taken, not when it was added to the mediagoblin instance.

This should be optional since not everyone might want this information to be visible.

User stories

Sysadmin makes creation date visible for media objects

Shaquannah the sysadmin updates the configuration file for her mediagoblin instance and sets original_date_visible to true to show when pictures (or other media objects with the corresponding EXIF information) were taken/created.

Visitor sees the creation date for a given media object

Spencer the guest browses to a media object's page and sees the date for when a picture (or other media object given EXIF information) was taken/created. Spencer sees this information in the sidebar, below the date indicating when the media object was added to the mediagoblin instance he's visiting.

Change History (12)

comment:1 by tryggvib, 12 years ago

Proposed fix in branch 532-exif-creation-date on gitorious user tryggvi's clone:

Version 0, edited 12 years ago by tryggvib (next)

comment:2 by tryggvib, 12 years ago

Owner: set to Christopher Allan Webber
Status: newassigned

comment:3 by Christopher Allan Webber, 11 years ago

Sorry for slow reply. Holidaze, and all that.

So thoughts: first of all, great idea!

There's one problem with splitting and re-joining the string this way in the template... it isn't localized. We could try to solve this via:

  • Putting the datetime object in the template context (that might be context creep, not sure).
  • Alternately we can pull the date out of the EXIF field and put it into a real, queryable SQL field in the ImageData table. The other advantage is that we could construct SQL queries on it if we for some reason wanted to. However, it would also require a migration, and I'm not 100% sure if it's worth it or not.
  • Another option which doesn't require adding such a field at all! Make a .created_date() method on the ImageData that does the same thing that's happening here in the template, but actually in the model. This doesn't require passing anything weird at all into the template, and thusly may be my preferred method!

I'd love to hear Elrond or etc's thoughts, but at the moment I think the last option may be the best?

Happy to walk you through this on IRC if you're willing to make that change! And thanks for taking the initiative on this!

comment:4 by Christopher Allan Webber, 11 years ago

Cc: Elrond added

comment:5 by Christopher Allan Webber, 11 years ago

Owner: changed from Christopher Allan Webber to tryggvib

comment:6 by tryggvib, 11 years ago

Owner: changed from tryggvib to Christopher Allan Webber

Went with the third method. For me it makes sense to move it from the view to the controller/model (I added a method called get_original_date() to the ImageDate model class.

The template now only checks if original_date_visible is set to true and then gets the original date via get_original_date (sets it to a variable). If the variable is None it doesn't add a thing. It it is visible it sets the date just like in Added on and wraps it in a translation block.

The get_original_date function tries to fetch exif_all's EXIF DateTimeOriginal (and under that "printable"). Then it uses datetime.datetime's strptime to read the string into a python datetime object and returns it (this is all in a try/except statement so that if anything goes wrong it returns None.

comment:7 by Christopher Allan Webber, 11 years ago

This is on my agenda to review shortly, btw :)

comment:8 by Christopher Allan Webber, 11 years ago

Keywords: review added

comment:9 by Elrond, 11 years ago

Related, but different: #642

532 is about showing more exif info.
642 is about having a db field for this stuff.

comment:10 by Christopher Allan Webber, 11 years ago

Owner: Christopher Allan Webber removed
Status: assignedreview

comment:11 by Christopher Allan Webber, 11 years ago

Resolution: fixed
Status: reviewclosed

This is finally, finally merged! :)

You did a great job on this... it's an embarassment it took so long. The new "review queue" workflow is helping though! :)

comment:12 by Christopher Allan Webber, 11 years ago

Milestone: 0.4.0
Note: See TracTickets for help on using tickets.