Title: Accessing WordPress&#039;s image upload functionality from a plugin
Last modified: August 19, 2016

---

# Accessing WordPress's image upload functionality from a plugin

 *  [Donal](https://wordpress.org/support/users/donalmacarthur/)
 * (@donalmacarthur)
 * [15 years, 3 months ago](https://wordpress.org/support/topic/accessing-wordpresss-image-upload-functionality-from-a-plugin/)
 * Does anyone know of an elegant way for plugins to hook into WordPress’s image
   upload functionality from their settings pages?
 * I’m building a gallery plugin at the moment and I’m trying to use as much of 
   the underlying WordPress functionality as possible to keep it simple and easy
   to maintain. This seems to be a sticking point though.
 * Basically I want to add an ‘insert image’ button on the plugin’s settings page
   that launches the familiar image dialogue box from the edit post screen. It should
   let the user upload a new image from their computer or select an existing image
   from their media library – exactly as it works when you’re adding an image to
   a post. If the user uploads an image it should process the uploaded file as normal,
   producing the thumbnail versions and adding an entry for the image in the media
   library. Either way, I’d like it to return the attachment ID of the selected 
   or newly added image for use in the gallery code.
 * All this functionality is built into WordPress already so it feels like there
   should be an easy way to do this – but if there is, I can’t find it. The solutions
   I’ve found so far have been hacky and look like they’d be messy to maintain.
 * Does anybody have any suggestions on how to go about this? I’m sure it’s a feature
   a lot of plugin and theme authors would like to make use of, so if I can get 
   it working I’ll write up a full tutorial and post it here.

The topic ‘Accessing WordPress's image upload functionality from a plugin’ is closed
to new replies.

## Tags

 * [images](https://wordpress.org/support/topic-tag/images/)
 * [media uploader](https://wordpress.org/support/topic-tag/media-uploader/)
 * [Upload Image](https://wordpress.org/support/topic-tag/upload-image/)

 * In: [Hacks](https://wordpress.org/support/forum/plugins-and-hacks/hacks/)
 * 0 replies
 * 1 participant
 * Last reply from: [Donal](https://wordpress.org/support/users/donalmacarthur/)
 * Last activity: [15 years, 3 months ago](https://wordpress.org/support/topic/accessing-wordpresss-image-upload-functionality-from-a-plugin/)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
