95 responses to “How To Integrate the WordPress Media Upload Box Into Your Meta Boxes”

  1. Pierre

    Hello there,

    Something weird with the media uploader: I use the “wp_get_attachment_image_src” function to display my images, which works correctly for brand new uploaded (from the computer) images, but fails in the case of yet existing images picked in the library: the URL is saved as meta date, but there is no more attachment with the post…
    Am I doing something wrong?

  2. Satrya

    Hi there,

    I got this error message
    Fatal error: Call to a member function setGroupName() on a non-object in mypath\custom-meta.php on line 5

    Can you explain this ?

    Thanks !

  3. cezarion


    I’had the same problem.
    in yourtheme/metabox/setup.php


    function my_metabox_styles()
        if ( is_admin() )
            wp_enqueue_style( 'wpalchemy-metabox', get_stylesheet_directory_uri() . '/metaboxes/meta.css' );

    add this line:

    $wpalchemy_media_access = new WPAlchemy_MediaAccess();
  4. Aris Blevins

    Hi Dimas,

    Amazing work on with WP Alchemy, I am really amazed at how clean and flexible this code is. Adding the Media Access functions is an exponential leap as well. Thanks!

    I am having a small issue, which may not be easily fixed. I have a CPT that I would like to attach two galleries to. I was originally going to have one gallery be created using the standard Attachment method, and then have meta fields pointing to the other images. With Media Access I was hoping I could include the second gallery as images uploaded via this meta-box – of course those images are just added to rest of the post gallery.

    Probably no way around this eh? Short of excluding those images from the gallery?

  5. Paul


    where would I set the upload path for it to be different from the regular media upload button at the top of the post edit screen?

  6. Paul

    I know that. What I mean is I want uploads managed by WP Alchemy to go to a different folder.
    I know there’s an ‘uploads_dir” filter hook for example. Maybe I can conditionally change the uploads folder when uploading with the wp alchemy metaboxes?

  7. Anders Kitson

    How do I go about outputting this in a template. specifically grabbing the imgurl from a certain page and displaying it on such. I have tried numerous things to no avail.

  8. Ian

    I’m using Netbeans, too…..

  9. Bebopweb

    I currently use the WordPress Media upload but I would like to add a sticker next to the delete button. Is this possible? If so, can you help me.
    Thank you in advance

  10. alrobeler

    Hi!how to display the above code
    in my theme?

  11. stephan

    Hi Dimas,

    Is there a way to prevent images from being added to the gallery?

    Thanks for all the hard work!

  12. Clay

    great library here but i faced a problem with the latest wp and i’m wondering whether this is an issue. Following all the instruction here, everything looks good until i start uploading images the insert button still said ‘Insert into Post’ instead of the one i customized it which cause it to keep inserting into the editor, any idea? :(

  13. Alan

    Could you please provide an example of how to save the value of ‘imgurl’ when the post is publsihed and then put it back in the field when the post is edited.


  14. Rafael Vinícius

    Hi Dimas

    Is there a way to prevent images from being added to the gallery?

  15. johnnya23

    Is it possible to retrieve the attachment id instead of the url and at the same time have some kind of useful feedback (not just the id#) to be shown on the dashboard?
    Thanks for a great plugin,

  16. tony

    Hi Dimas,

    Good Day, I copied the same code for the media repeater however i kept getting error Fatal error: Call to a member function setGroupName() on a non-object in C:\wamp\www\site\wp-content\themes\windsorblinds\backend\functions\metaboxes\product-meta.php on line 38

    version 1.5.2



  17. slona

    How to echo the fields into my theme? Using
    foreach ($meta['docs'] as $link)
    I get “Invalid argument supplied for foreach()”

  18. slona

    Ooops, my falut, I messed up variable names. It’s working now. Echo the fields using:

    global $custom_mb;
    $meta = $custom_mb->the_meta();

    foreach ($meta['docs'] as $link)
    echo $link['imgurl'];

Leave a Reply