We use cookies to improve your experience. No personal information is gathered and we don't serve ads. Cookies Policy.

ExpressionEngine Logo ExpressionEngine
Features Pricing Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University
Log In or Sign Up
Log In Sign Up
ExpressionEngine Logo
Features Pro new Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University Blog
  • Home
  • Forums

best way to add thousands of photos to gallery

Development and Programming

Michael C.'s avatar
Michael C.
29 posts
17 years ago
Michael C.'s avatar Michael C.
For the two of who PM’ed me, I promise, I will get to it this weekend.

Only 2 people, eh? Curious - I’d have expected a deluge. 😊

Question: From what I can see, the script uses the current server time as the photo’s date:

'entry_date' => time()

Is there an easy way to adjust it to use the EXIF data? Looks like it shouldn’t be too hard.

       
Erin Dalzell's avatar
Erin Dalzell
790 posts
17 years ago
Erin Dalzell's avatar Erin Dalzell

It shouldn’t be too hard, you’re right. In fact I have an extension that sets it when I manually upload my photos.

However, it is not likely that I get it done as I am quite busy right now. Feel free to modify it though and redistribute.

       
Erin Dalzell's avatar
Erin Dalzell
790 posts
17 years ago
Erin Dalzell's avatar Erin Dalzell

OK, I have attached the module below.

BE WARNED THAT THIS IS VERY ROUGH!!! USE AT YOUR OWN RISK!

It uses your gallery’s upload directory and batch directory.

Install as usual then go to the module to move the files. The images must already be in your batch upload directory. And the upload only puts things in one category, so if you have many images you need to put into many categories it won’t work so well.

Please feel free to modify this code and make it your own. I make no claim on this, so if someone wants to take it and support it or expand it, please do.

       
Michael C.'s avatar
Michael C.
29 posts
17 years ago
Michael C.'s avatar Michael C.

THANK YOU!!!!!!!

I made some adjustments so that it used the JPG’s EXIF datetime as the entry’s date/time, and it worked like a charm! 1500 pictures inserted into the database in approx 60 seconds - awesome!!

       
Erin Dalzell's avatar
Erin Dalzell
790 posts
17 years ago
Erin Dalzell's avatar Erin Dalzell

Glad I could help.

       
Michael C. (KKCJ)'s avatar
Michael C. (KKCJ)
100 posts
17 years ago
Michael C. (KKCJ)'s avatar Michael C. (KKCJ)

Does anyone want the adjusted version with the EXIF data used as the entry time? Speak now…

       
Erin Dalzell's avatar
Erin Dalzell
790 posts
17 years ago
Erin Dalzell's avatar Erin Dalzell

Yes please

       
Michael C.'s avatar
Michael C.
29 posts
17 years ago
Michael C.'s avatar Michael C.

Sorry it took so long. The only lines that I changed (IIRC) were line 168 and line 171 of mcp.gallery_batch_uploader.php, to read as follows:

Line 168:

'title' => date('Y-m-d H:i:s', strtotime($exif_datetime['EXIF']['DateTimeOriginal'])),

Line 171:

'entry_date' => strtotime($exif_datetime['EXIF']['DateTimeOriginal']) - 7200 );

For line 168, I formatted the entry title to be a human-readable date/time stamp, in universal format. Feel free to adjust accordingly.

For line 171, I had to adjust the date/time by -7200 to correct a strange time difference I was encountering between the EXIF data and the timestamp used for that picture’s entry in EE. I’ve no idea whether this is a unique thing to my server or photos, or if everyone else will encounter the same thing. I suggest you upload 2-5 pics as a test and see what results you get before using this on a gazillion files.

In case I forgot an alteration I did on any other lines, I’m attaching the files themselves to this post.

Thanks once again for this script, Erin - it’s been a MASSIVE help! 😊

       
Erin Dalzell's avatar
Erin Dalzell
790 posts
17 years ago
Erin Dalzell's avatar Erin Dalzell

Glad I could help. Please feel free to take ownership of this for your uses…I only put it together quickly to help out.

       
1 2

Reply

Sign In To Reply

ExpressionEngine Home Features Pro Contact Version Support
Learn Docs University Forums
Resources Support Add-Ons Partners Blog
Privacy Terms Trademark Use License

Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.