Launch new image scan programatically
-
Hi,
[echoing/describing the feature request made earlier]
I have set a standard image gallery (WP MU) with a particular directory (/wp-content/uploads/sites/[blog_ID]/ngg-gallery).What I need is that uploaded files within this directory are imported into the gallery at the end of the upload (that’s another part, dealing with gravity forms).
Basically, it’s exactly what we can trigger manually in the gallery settings by clicking the button “scan for new images”.
I thought I could “retro-engineer” and add my own function to do that but I’d say that I’m ending with a few concerns about reliability and durability.
Here’s where I am right now$gallerypath = $wpdb->get_var("SELECT path FROM $wpdb->nggallery WHERE name = 'my-import-gallery' "); $gallery_id = $wpdb->get_var("SELECT gid FROM $wpdb->nggallery WHERE name = 'my-import-gallery' "); // read list of images $new_imageslist = array_diff(scandir($gallerypath), array('..', '.','thumbs')); $old_imageslist = $wpdb->get_col("SELECT filename FROM $wpdb->nggpictures WHERE galleryid = $gallery_id "); $new_images = array_diff($new_imageslist, $old_imageslist);
So, I have the gallery_id, the image(s) to import array and I wish I could “simply” call a function like
nggAdmin::add_Images($galleryID, $new_images);
But I believe it’s restricted for admin area only (or I’m missing something obvious for PHP experts …).Note : as of now I’m using the free version but I’ll be glad to jump to the Pro version if this was achievable.
BR,
Antoine aka Superfly
- The topic ‘Launch new image scan programatically’ is closed to new replies.