Plugin Development - Adding an Image

I’ve been trying to figure this out for a long time and can never get any help on the Wordpress plugin forum. :frowning:

Hopefully you guys can help me out here…

I’m trying to create a plugin where users can upload an image.

WordPress already has a built in image uploader and manipulator - so how do I instantiate it and utilize it in my plugin?

Yeah that’s definitely a start! Thank you.

What I’m really hoping to accomplish is something similar to what you see when you create a new Post. Above the description box, there’s the text that says “Upload/Insert”, and then you have the little icon next to it for adding an Image.

I want to simply use that in my plugin. When a person clicks on the icon for “image”, the overlay box pops up and I get the upload screen where I can upload the image and then select the image i want to use.

Thanks for any assistance :slight_smile:

Maybe you want the wp-admin/media-upload.php file?

 * Manage media uploaded file.
 * There are many filters in here for media. Plugins can extend functionality
 * by hooking into the filters.
 * @package WordPress
 * @subpackage Administration

I believe the file you’re interested in using is the wp-includes/media.php file?

If so it has ~42 functions

class WP_Embed 
function __construct()
function _wp_post_thumbnail_class_filter( $attr )
function _wp_post_thumbnail_class_filter_add( $attr )
function _wp_post_thumbnail_class_filter_remove( $attr )
function add_image_size( $name, $width = 0, $height = 0, $crop = FALSE )
function adjacent_image_link($prev = true, $size = 'thumbnail', $text = false)
function autoembed( $content )
function autoembed_callback( $match )
function cache_oembed( $post_ID )
function delete_oembed_caches( $post_ID )
function gallery_shortcode($attr)
function gd_edit_image_support($mime_type)
function get_attachment_taxonomies($attachment)
function get_image_tag($id, $alt, $title, $align, $size='medium')
function image_constrain_size_for_editor($width, $height, $size = 'medium')
function image_downsize($id, $size = 'medium')
function image_get_intermediate_size($post_id, $size='thumbnail')
function image_hwstring($width, $height)
function image_make_intermediate_size($file, $width, $height, $crop=false)
function image_resize( $file, $max_w, $max_h, $crop = false, $suffix = null, $dest_path = null, $jpeg_quality = 90 )
function image_resize_dimensions($orig_w, $orig_h, $dest_w, $dest_h, $crop = false)
function img_caption_shortcode($attr, $content = null)
function maybe_make_link( $url )
function maybe_run_ajax_cache()
function next_image_link($size = 'thumbnail', $text = false)
function previous_image_link($size = 'thumbnail', $text = false)
function register_handler( $id, $regex, $callback, $priority = 10 )
function run_shortcode( $content )
function set_post_thumbnail_size( $width = 0, $height = 0, $crop = FALSE )
function shortcode( $attr, $url = '' )
function unregister_handler( $id, $priority = 10 )
function wp_constrain_dimensions( $current_width, $current_height, $max_width=0, $max_height=0 )
function WP_Embed()
function wp_embed_defaults()
function wp_embed_register_handler( $id, $regex, $callback, $priority = 10 )
function wp_embed_unregister_handler( $id, $priority = 10 )
function wp_expand_dimensions( $example_width, $example_height, $max_width, $max_height )
function wp_get_attachment_image($attachment_id, $size = 'thumbnail', $icon = false, $attr = '')
function wp_get_attachment_image_src($attachment_id, $size='thumbnail', $icon = false)
function wp_imagecreatetruecolor($width, $height)
function wp_oembed_add_provider( $format, $provider, $regex = false )
function wp_oembed_get( $url, $args = '' )

And these Codex links might help

Just bumping in hopes of getting an answer :frowning:

I’ve looked at other plugins that utilize image uploading, but they all use their own script to upload, resize, and crop the image…but it just seems like re-inventing the wheel. WP already has this functionality - I just want to utilize it.