Title: Custom Plugin Modify On Upload
Last modified: August 22, 2016

---

# Custom Plugin Modify On Upload

 *  Resolved [twistedindustries](https://wordpress.org/support/users/twistedindustries/)
 * (@twistedindustries)
 * [11 years, 8 months ago](https://wordpress.org/support/topic/custom-plugin-modify-on-upload/)
 * As I’ved searched and there isn’t any documentation for developers and its been
   said to ‘just ask’ here I go.
 * My clients wants to be able to color tag photos to search via color. I haven’t
   found anything that does this or even something close so a bump in the right 
   direction would be helpful.
 * In order to start writing a custom plugin to do so I thought it would be nice
   to pull a sample palette on upload. That would mean that I need to hook into 
   that upload process. My API question is how can I hook into the upload method?
   Even if I wanted to just take the filename and add it as a tag as a simple example.
   I don’t see any way to hook in and modify data in the function upload_image or
   upload_base64_image.
 * [https://wordpress.org/plugins/nextgen-gallery/](https://wordpress.org/plugins/nextgen-gallery/)

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

 *  [Benjamin](https://wordpress.org/support/users/benjaminowens/)
 * (@benjaminowens)
 * [11 years, 8 months ago](https://wordpress.org/support/topic/custom-plugin-modify-on-upload/#post-5352357)
 * You can use one of our two actions that upload_base64_image() runs:
 * ngg_added_new_image (passes $image object)
    ngg_after_new_images_added (passes
   gallery id and image id)
 *     ```
       add_action('ngg_added_new_image', 'check_ngg_palette');
       function check_ngg_palette($image) {
           $storage = C_Gallery_Storage::get_instance();
           $image_fs_path = $storage->get_image_abspath($image);
       }
       ```
   
 * You should be able to safely add attributes to $image and save them with the 
   following:
 *     ```
       $image_mapper = C_Image_Mapper::get_instance();
       $image_mapper->save($image);
       ```
   
 * but I would generally recommend using your own storage methods for any attributes
   that NextGen doesn’t set itself.
 * I hope that helps!
 *  Plugin Contributor [photocrati](https://wordpress.org/support/users/photocrati/)
 * (@photocrati)
 * [11 years, 8 months ago](https://wordpress.org/support/topic/custom-plugin-modify-on-upload/#post-5352359)
 * [@benjamin](https://wordpress.org/support/users/benjamin/) – Thanks! 🙂
 * – Cais.
 *  Thread Starter [twistedindustries](https://wordpress.org/support/users/twistedindustries/)
 * (@twistedindustries)
 * [11 years, 8 months ago](https://wordpress.org/support/topic/custom-plugin-modify-on-upload/#post-5352377)
 * Right on, this looks like it will help a ton! Thanks!

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

The topic ‘Custom Plugin Modify On Upload’ 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

 * [api](https://wordpress.org/support/topic-tag/api/)
 * [hook](https://wordpress.org/support/topic-tag/hook/)
 * [upload](https://wordpress.org/support/topic-tag/upload/)

 * 3 replies
 * 3 participants
 * Last reply from: [twistedindustries](https://wordpress.org/support/users/twistedindustries/)
 * Last activity: [11 years, 8 months ago](https://wordpress.org/support/topic/custom-plugin-modify-on-upload/#post-5352377)
 * Status: resolved