Title: NextGEN   WP/LR Sync
Last modified: August 30, 2016

---

# NextGEN WP/LR Sync

 *  Resolved [Jordy Meow](https://wordpress.org/support/users/tigroumeow/)
 * (@tigroumeow)
 * [10 years, 10 months ago](https://wordpress.org/support/topic/nextgen-wplr-sync/)
 * Hello,
 * You actually contacted me to propose me a job 🙂 But I like my independence. 
   I proposed you to collaborate instead and to make our projects work together.
   Since that, you just disappeared. Tried to send you one or two more e-mails, 
   no replies 🙁 Please, for the sake of our users, and even for ourselves. Let’s
   make our plugins to work together. It’s an advantage for everyone here.
 * I wanted you to help me implement support for your plugin but I am doing it myself
   since it seems there is no choice. However, I am running into one particular 
   issue.
 * I would like to reference an image that already exists in the Media Library in
   your ngg_pictures table. But it seems you only store files directly and their
   location depends on the gallery they belong to (ngg_gallery->path).
 * 1. Is there a way I could reference directly to an image in the Media Library?
 * 2. Alternatively, can I use one of your function to point to a specific media
   file and your plugin will copy it into a specific gallery/path?
 * Thanks for your help.
 * [https://wordpress.org/plugins/nextgen-gallery/](https://wordpress.org/plugins/nextgen-gallery/)

Viewing 11 replies - 1 through 11 (of 11 total)

 *  Plugin Contributor [photocrati](https://wordpress.org/support/users/photocrati/)
 * (@photocrati)
 * [10 years, 10 months ago](https://wordpress.org/support/topic/nextgen-wplr-sync/#post-6372339)
 * [@jordy](https://wordpress.org/support/users/jordy/) Meow – As noted in your 
   other topic, you are more than welcome to contact us via our Contact form here:
   [http://nextgen-gallery.com/contact/](http://nextgen-gallery.com/contact/)
 * If you did not receive any response to your previous message, please send it 
   again just in case it got missed or lost to spam.
 * We can then help you get in contact with one of our developers for additional
   assistance … we are also preparing additional general documentation that may 
   be of further help as well.
 * Also to note, we are a small team with limited resources, our developers may 
   not have had time to digest your message and respond, yet.
 * Thanks!
 * – Cais.
 * PS: I have also tagged this topic for our developers to review as well.
 *  Thread Starter [Jordy Meow](https://wordpress.org/support/users/tigroumeow/)
 * (@tigroumeow)
 * [10 years, 10 months ago](https://wordpress.org/support/topic/nextgen-wplr-sync/#post-6372340)
 * Understood. It’s for the best of everyone including Photocrati, which is why.
   If possible, it would be great if someone could contact me directly at [apps@meow.fr](https://wordpress.org/support/topic/nextgen-wplr-sync/apps@meow.fr?output_format=md)
   🙂
 *  Plugin Contributor [photocrati](https://wordpress.org/support/users/photocrati/)
 * (@photocrati)
 * [10 years, 10 months ago](https://wordpress.org/support/topic/nextgen-wplr-sync/#post-6372343)
 * [@jordy](https://wordpress.org/support/users/jordy/) Meow – As noted, please 
   use our contact form for the fastest results.
 * – Cais.
 *  Thread Starter [Jordy Meow](https://wordpress.org/support/users/tigroumeow/)
 * (@tigroumeow)
 * [10 years, 10 months ago](https://wordpress.org/support/topic/nextgen-wplr-sync/#post-6372403)
 * I contacted you 2 times already and the only answers I get are through this forum
   🙁 I just sent you another email through the link you gave me.
 * Apart from that, can you give me support on those questions? That would definitely
   help:
 * I would like to reference an image that already exists in the Media Library in
   your ngg_pictures table. But it seems you only store files directly and their
   location depends on the gallery they belong to (ngg_gallery->path).
 * 1. Is there a way I could reference directly to an image in the Media Library?
 * 2. Alternatively, can I use one of your function to point to a specific media
   file and your plugin will copy it into a specific gallery/path?
 *  [Benjamin](https://wordpress.org/support/users/benjaminowens/)
 * (@benjaminowens)
 * [10 years, 10 months ago](https://wordpress.org/support/topic/nextgen-wplr-sync/#post-6372447)
 * I’m afraid I don’t understand your first question but I can answer the second.
 *     ```
       $id = 23; // insert your own Media Library attachment ID
       $abspath    = get_attached_file($id);
       $file_data  = file_get_contents($abspath);
       $file_name  = M_I18n::mb_basename($abspath);
       $attachment = get_post($id);
       $storage    = C_Gallery_Storage::get_instance();
       $mapper     = C_Image_Mapper::get_instance();
   
       $image = $storage->upload_base64_image($gallery_id, $file_data, $file_name);
   
       // Potentially import metadata from WordPress
       $image = $image_mapper->find($image->id());
       if (!empty($attachment->post_excerpt))
           $image->alttext = $attachment->post_excerpt;
       if (!empty($attachment->post_content))
           $image->description = $attachment->post_content;
   
       $image_mapper->save($image);
       ```
   
 * All it requires is that NextGen be loaded and that you know your media library
   image ID. You can see more or less the above in action in a method named import_media_library_action()
   if you search the NextGen code.
 *  Thread Starter [Jordy Meow](https://wordpress.org/support/users/tigroumeow/)
 * (@tigroumeow)
 * [10 years, 10 months ago](https://wordpress.org/support/topic/nextgen-wplr-sync/#post-6372459)
 * Hey Benjamin, thanks a lot for helping 🙂
 * In my first question, I wanted to add the image my myself directly into the ngg_pictures
   table of NextGEN. That way I could have referenced something directly from the
   Media Library 🙂
 * The alternative you proposed me is better anyway because it uses NextGEN functions.
   I will do that.
 *  Thread Starter [Jordy Meow](https://wordpress.org/support/users/tigroumeow/)
 * (@tigroumeow)
 * [10 years, 10 months ago](https://wordpress.org/support/topic/nextgen-wplr-sync/#post-6372557)
 * Hello,
 * I have another question linked to the code you posted Benjamin. What about deleting
   this image from the library now? How to do it simply?
 *  [Benjamin](https://wordpress.org/support/users/benjaminowens/)
 * (@benjaminowens)
 * [10 years, 10 months ago](https://wordpress.org/support/topic/nextgen-wplr-sync/#post-6372592)
 * You can do that with the following:
    `C_Gallery_Storage::get_instance()->delete_image(
   $image_id)`
 * I have some been working on some (still in progress, only roughly edited, and
   unofficial for now) [documentation on the NGG API](https://0x18.us/using-the-nextgen-gallery-2-1-api/)
   that may help.
 *  Thread Starter [Jordy Meow](https://wordpress.org/support/users/tigroumeow/)
 * (@tigroumeow)
 * [10 years, 10 months ago](https://wordpress.org/support/topic/nextgen-wplr-sync/#post-6372593)
 * Hello Benjamin!
 * I figured that out, it was easy since it was still in that storage class. My “
   extension” for NextGEN allows synchronization with Lightroom but it doesn’t make
   you independent from NextGEN, you can basically use any gallery plugins or try
   another one, or use your themes galleries.
 * If you want to see the code for the extension, it is here:
    [https://github.com/jordymeow/wplr-nextgen](https://github.com/jordymeow/wplr-nextgen)
 * Actually I think I still have an issue with NextGEN, is about the folder. I don’t
   know how they make a folder belongs to another one, I didn’t find the link between
   the two.
 * Your documentation is really great, I will add a link to it in the plugin description,
   in case somebody wants to add a feature or do something specific. Thanks a lot
   for doing that!
 *  [Benjamin](https://wordpress.org/support/users/benjaminowens/)
 * (@benjaminowens)
 * [10 years, 10 months ago](https://wordpress.org/support/topic/nextgen-wplr-sync/#post-6372594)
 * “NextGEN for Lightroom” looks good; the only suggestion I’d make is rather than
   calling $wpdb->delete() in remove_collection() I would use `C_Gallery_Mapper::
   get_instance()->destroy($gallery or $gallery_id, TRUE)` as it will remove tags
   that are no longer associated with images, optionally remove the relevant directory
   for the gallery, invoke the “ngg_delete_gallery” action, and flush the displayed
   gallery rendering cache.
 *  Thread Starter [Jordy Meow](https://wordpress.org/support/users/tigroumeow/)
 * (@tigroumeow)
 * [10 years, 10 months ago](https://wordpress.org/support/topic/nextgen-wplr-sync/#post-6372598)
 * Thanks a lot Benjamin. I have just released a new version of the extension. No
   more $wpdb, it’s always using NextGEN internal functions. Much better. Again,
   big thanks 🙂

Viewing 11 replies - 1 through 11 (of 11 total)

The topic ‘NextGEN WP/LR Sync’ is closed to new replies.

 * ![](https://ps.w.org/nextgen-gallery/assets/icon-256x256.png?rev=2083961)
 * [Photo Gallery, Sliders, Proofing and Themes - NextGEN Gallery](https://wordpress.org/plugins/nextgen-gallery/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/nextgen-gallery/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/nextgen-gallery/)
 * [Active Topics](https://wordpress.org/support/plugin/nextgen-gallery/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/nextgen-gallery/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/nextgen-gallery/reviews/)

## Tags

 * [nextgen](https://wordpress.org/support/topic-tag/nextgen/)

 * 11 replies
 * 3 participants
 * Last reply from: [Jordy Meow](https://wordpress.org/support/users/tigroumeow/)
 * Last activity: [10 years, 10 months ago](https://wordpress.org/support/topic/nextgen-wplr-sync/#post-6372598)
 * Status: resolved