Edit the Date/Time an item was created in Gallery

rWatcher
rWatcher's picture

Joined: 2005-09-06
Posts: 722
Posted: Tue, 2009-09-01 00:34

This module will allow you to manually edit the date/time that an album was created in Gallery and the date/time a photo or video was uploaded to Gallery. I find this can be useful when sorting an album's contents. This module has been tested against Gallery 3.0.2.

[img]http://codex.gallery2.org/images/8/8c/Editcreation.jpg[/img]

---
Report Problems/Suggestions Here | Get latest version | Documentation | Coffee Fund | My Library | My GitHub

AttachmentSize
editcreation.zip2.89 KB
 
floridave
floridave's picture

Joined: 2003-12-22
Posts: 27300
Posted: Tue, 2009-09-01 05:54

Great addition!

From what I can recall in G2 some users wanted to be able to edit the origination date. Some items are scanned and don't have an proper origination date. There was also a issue with items prior to 1970. Would be cool to have that issue fixed by a module as well.

Dave

_____________________________________________
Blog & G2 || floridave - Gallery Team

 
rWatcher
rWatcher's picture

Joined: 2005-09-06
Posts: 722
Posted: Tue, 2009-09-01 06:40
floridave wrote:
Great addition!

From what I can recall in G2 some users wanted to be able to edit the origination date. Some items are scanned and don't have an proper origination date.

Would that be the "captured" field in the items table? If so then I could probably write a module (or expand this one) to allow editing of that field as well.

floridave wrote:
There was also a issue with items prior to 1970. Would be cool to have that issue fixed by a module as well.

Dave

Well, it would help if I knew the exact issue :) , but just looking at Gallery's code it appears Gallery is using the PHP time function when it sets the "created" date. From http://us3.php.net/time

Quote:
Returns the current time measured in the number of seconds since the Unix Epoch (January 1 1970 00:00:00 GMT).

My guess would be any issue with dates before 1970 would be tied to that. I'd have to do some more digging to see if it's something a module could fix though.

 
MyFault
MyFault's picture

Joined: 2008-09-20
Posts: 3
Posted: Tue, 2009-09-01 07:03
Quote:
Would that be the "captured" field in the items table? If so then I could probably write a module (or expand this one) to allow editing of that field as well.

It looks like "captured" is the time from the EXIF, "created" is when the item was added to Gallery3, and "updated" is when the item changed, although it seems like the "updated" time isn't always changed (for example, when a new item is added to an album). A module (or modules) to edit all three of these times from the Gallery UI (like G2 had) would be ideal.

Quote:
My guess would be any issue with dates before 1970 would be tied to that. I'd have to do some more digging to see if it's something a module could fix though.

I just checked with the version running on my development server. I set the captured date for an item to -12345678, and G3 reported a capture date of Aug. 10, 1969, 7:38pm (which is correct, after my time-zone offset). I was directly manipulating the database to change this, so I don't know if the Gallery code will allow it, but the back-end MySQL and PHP apparently allow for negative values in these date fields.

 
jayp

Joined: 2005-10-24
Posts: 52
Posted: Sun, 2009-09-20 22:05

Fantastic module rWatcher.

I'm having one problem in G3 beta3. Everything stills works like a charm, except that when I edit an album or photo, the edit form will not close and I do not see the ajax update. If I close the form or hit cancel and refresh the page, then I see the ajax message notifying me that the changes were saved, and whatever change I made (from the album name to the created date) are indeed saved. If I disable the module, I can once again edit albums or photos and the form now closes and the ajax message is displayed immediately.

Thanks!

 
jayp

Joined: 2005-10-24
Posts: 52
Posted: Sun, 2009-09-20 22:33

Well, I'm a little OCD and have managed to fix the problem. Oddly enough, it seems to have been caused by the inline styles you printed into the edit form. I'm using Firefox 3.5, and so I don't know if this problem exists in all browsers and platforms or just mine.

At any rate, here's what I did.

In editcreation_event.php, remove the lines that read:

    // Inject some css to make everything look right.
    print ("<style>\nselect {\ndisplay: inline;\n}\n</style>\n");

Now inside modules/editcreation, create a new folder named "css" and create a new file in it named "editcreation.css".

Inside this new file at modules/editcreation/css/editcreation.css, add the following:

select {
  display: inline;
}

Now create a new file at modules/editcreation/helpers/editcreation_theme.php, and add the following:

<?php defined("SYSPATH") or die("No direct script access.");
class editcreation_theme {
  static function head($theme) {
    $item = $theme->item();
    //only print out styles to users with editing rights who are looking at an item
    if ( $item && access::can("edit", $item) ) {
      $theme->css("editcreation.css");
    }
  }
}

Now I can edit an album or photo and the edit form closes and I see a successful ajax message.

 
griffinmt
griffinmt's picture

Joined: 2009-09-06
Posts: 128
Posted: Mon, 2009-09-21 01:04

With regard to making changes to a pictures 'Taken Date' or 'Captured Date', especially if the jpg in question has no EXIF or IFD data, you would be better off using a tool like GeoSetter to insert this info before uploading to the gallery. That would also be a great time to load it with a thumbnail internally too.

That way Gallery doesn't have to take responsibility for altering the EXIF content on any pictures.

Martyn T. Griffin

 
rWatcher
rWatcher's picture

Joined: 2005-09-06
Posts: 722
Posted: Wed, 2009-09-30 20:35

@jayp
Thanks! I've incorporated your changes into a revised version of this module.

@griffinmt
This doesn't touch the exif at all, it just allows you to edit the value Gallery stores in it's database. Editing the exif before uploading is definitely a better idea, but you can't always do that (for example with videos or albums).

 
sddroog

Joined: 2005-02-01
Posts: 132
Posted: Tue, 2010-03-02 10:10

Sorry to dig up an old thread. And thanks for this useful module!

There is just one thing I don't understand: I have set all the dates on my albums manually in G2 (Edit Album, Album Date and Time), but after import the dates I see with this module seems to be the original creation date of the albums... and I have to set all the dates again!?

 
surgeon

Joined: 2005-01-18
Posts: 80
Posted: Tue, 2010-03-02 10:16

I have same daubts about imported dates from G2 as sddroog. :)

 
rWatcher
rWatcher's picture

Joined: 2005-09-06
Posts: 722
Posted: Thu, 2010-03-04 02:39

Perhaps it's a bug in the g2 import module? You could open up a new thread and see if anyone else has problems with it.

 
sddroog

Joined: 2005-02-01
Posts: 132
Posted: Sun, 2010-03-07 15:22

Hi rWatcher,

Thanks. I investigated a bit more, and there seems to be two dates for every item in Gallery3, "captured" and "created". It is mentioned before by others as well earlier in this thread. Your great module allows to edit the created date (the date the item was uploaded to Gallery3) but not the captured date.

For albums, it seems that the g2_import takes the original creation date only. It doesn't set the captured date (can an album have a captured date?)

For items, I think the g2_import takes the captured date and the original creation date, and sets the two dates in G3 accordingly.

I usually make sure the exif date is correct before uploading, but for movies this is not possible. And because there is no way to set the captured date for those items, the sorting will be messed up.

It is possible to extend your module to allow editing the captured date also?

And I would very much appreciate European date format support. I can't get used to m/d/y and am/pm. Europeans prefer d/m/y and a 24 hour clock. Or did I miss a setting somewhere?

 
yemble

Joined: 2008-07-29
Posts: 2
Posted: Mon, 2010-09-06 10:27

I wanted an easy way to update the captured date too so I patched the editcreation module to add that field.

Note: if there is no captured date on the item (eg for an album) then it looks for the most recent date on the child items and uses that as the default value. ie if you edit an album, it will take on the most recent date from the album contents by default.

Here's the diff: http://pastie.org/1141168

Silly screenshot attached.

 
bharat
bharat's picture

Joined: 2002-05-21
Posts: 7994
Posted: Mon, 2010-09-06 18:21

@yemble: if you create a fork from github and push these changes up to your fork, I'll pull your changes into the gallery3-contrib repo for everybody to use.
---
Problems? Check gallery3/var/logs
bugs/feature req's | upgrade to the latest code | use git

 
xmod

Joined: 2010-10-08
Posts: 21
Posted: Wed, 2010-10-13 11:55

Hi to all

Based on the editcreation module and its modification editcreationcaptured, I coded a new module called "editcaptured". In adition to the already existing modules it offers some more options in choosing which date to set (arbitrary date, date of oldest child, date of youngest child, current date, remove date).

The module and discussions can be found here in this forum: http://gallery.menalto.com/node/98508. There is also a wiki page: http://gallery.menalto.com/node/98508

Just did that because depending on wheather there exist a captured date for an item, I want to show a date or I don't want to show a date at all but still want to now when the item was created. And sometimes I want to have some albums wich aren't related to a specific date. If the new options are liked, one can also think about combinding the creation and the captured date module again and use the extended options also for creation date.

Best regards,
xMod

 
floridave
floridave's picture

Joined: 2003-12-22
Posts: 27300
Posted: Tue, 2010-10-12 03:30

xmod,
Please start a new new thread with your module. I have started a codex page for it:
http://codex.gallery2.org/index.php?title=Gallery3:Modules:editcaptured
Feel free to make corrections & additions I have missed.
One issue I noticed was the form elements (dropdowns) are not horizontal and are not pre-populated with the current value.

Dave
_____________________________________________
Blog & G2 || floridave - Gallery Team