NextGEN Gallery – Feature Addition – Import Zip From URL
So I work with the NextGEN Gallery plugin pretty often for various websites and one of the things we constantly find ourselves doing is downloading zip files of content, then uploading them to the system in order to import them. From time to time I would run into a max upload size problem which meant uploading outside the usual interface or doing things in portions.
I decided I needed to get around this problem so I went ahead and made what turned out to be a pretty simple modification of the NextGEN Gallery plugin. Here’s what I did:
- I modified admin/functions.php and added a function:
import_zipfile_from_url($galleryID) - I modified admin/addgallery.php in various spots
The first modification is easiest, I just took the code from the import_zipfile function and modified it so that rather then expecting the file from the $_FILES variable I used curl to grab the zip file from the URL, save it to the /tmp directory with a random name, then followed the process from the original function. Easy!
The only other modification that was needed was the admin form for adding a gallery. The file that handles that is admin/addgallery.php and after taking a look at it I found it really wasn’t a complex form at all. I did the following:
- I modified the <ul> with the id “tabs” adding the following pointing the link to the following: <a href=”#zipimport”>
- Then I added a div with the actual form with the id “zipimport” – it takes in the url for the zip file and the gallery selection
- Finally I added another POST variable check: $_POST['zipimport'] which executes the new function which was added to functions.php
Test it out, as long as PHP was compiled with cURL this should work pretty smoothly. You can grab a copy of the files I modified from here:
http://files.gimmesoda.com/nextgen/nextgen_gallery_mod.zip
Let me know if you have any questions!