Support » Plugins » Hacks » Howto integrate the Media Library into a plugin?

  • Hey,

    Im writing a plugin.

    In that I would like to offer that people can add images.

    I could write a new function and make my own upload-dir but howto re-use the Media Library, so I could add/upload images and select already uploaded images?

Viewing 3 replies - 1 through 3 (of 3 total)
  • It wasnt that hard…

    See this revision history to see how I did…

    Basicly what I did was adding this to my plugin:

    function wp_gear_manager_admin_scripts() {
    function wp_gear_manager_admin_styles() {
    add_action('admin_print_scripts', 'wp_gear_manager_admin_scripts');
    add_action('admin_print_styles', 'wp_gear_manager_admin_styles');

    And later this part:

    <script language="JavaScript">
    jQuery(document).ready(function() {
    jQuery('#upload_image_button').click(function() {
    formfield = jQuery('#upload_image').attr('name');
    tb_show('', 'media-upload.php?type=image&TB_iframe=true');
    return false;
    window.send_to_editor = function(html) {
    imgurl = jQuery('img',html).attr('src');
    <tr valign="top">
    	<td>Upload Image</td>
    	<td><label for="upload_image">
    		<input id="upload_image" type="text" size="36" name="upload_image" value="<?php echo $gearimage; ?>" />
    		<input id="upload_image_button" type="button" value="Upload Image" />
    		<br />Enter an URL or upload an image for the banner.

    Thank you very much for this! I had a hard time finding info on how to do this and your post is excellent example.


    I don’t know if you still follow this post, since it’s eleven months old. I like the way this works. What about audio? Would somebody be able to show me how you use jQuery to get the audio file, say MP3. I want to do something like this, but this doesn’t work.

    <input type=”text” name=”MP3[URL]” id=”upload_audio”>

    window.send_to_editor = function(html) {
    audioURL = jQuery(‘audio’,html).attr(‘src’);

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Howto integrate the Media Library into a plugin?’ is closed to new replies.