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

  1. pixenjoy

    Hello Dimas,

    I would like to translate the “Add Media” button label with the php gettext functions but this label is a string in your MediaAcces.php file.

    It could be great to be able to translate this label in other languages in your next release.

  2. Bill

    Hi, is there a way to have a field in a meta box that accepts a single file upload? I’d for my users to be able to attach/upload a resume to a post. One resume per post. I’d like it to be a PDF file, too. But, I am not sure how I’d do this.

    If possible, I’d like to avoid exposing the user to the media gallery…

    thanks!

  3. Pietro

    Hi, there is no example code? It’s a little bit difficult read/copy the code in the youtube video :) Tnx

  4. John Westbroek

    First of all, thanks for the MetaBox PHP class, it’s a real time-saver and hasn’t let me down so far.

    I’m running into a few problems using the MediaAccess class. When using it with regular posts it works fine but on Custom Post Types the “Insert” button doesn’t show up in the MediaUpload-box and is replaced by the original “Insert this” button (which doesn’t work). Also on PDF-files no button is showing at all. Could you help with this?

  5. shawn

    I saw the comment about the media preview images in the admin from pastebin, but I don’t see the code in the mediaaccess.php file.
    http://pastebin.com/SLWhkbnm

    I’ve tried adding it in myself, but keep getting it wrong.

    Any chance you could provide a modified vs. of mediaaccess that properly includes the image preview?

    love the script!

  6. pixenjoy

    Hello,

    Just a note : I use the theme-check plugin to test my theme and make sure it’s up to spec with the latest WP theme review standards.

    And when i ckeck my theme, this message display :


    WARNING: Found eval in the file /metabox/MediaAccess.php. eval() is not allowed..
    Line 355: data = eval('(' + (data.indexOf('{') < 0 ? '{' + data + '}' : data) + ')');

    Is it possible to replace the “eval” code by another instruction ? WordPress seems not appreciate eval() function.
    Maybe for the next update ;-)

  7. Aaron Vanderzwan

    MediaAccess is great!

    Not a show-stopper, just an FYI. The default editor has to be enabled in order for the MediaAccess ‘Insert’ button to show up (as of 0.1.1). It seems WordPress removes the button completely if the editor is not supported. So… if you are defining your own custom types, just make sure to include ‘editor’ in your ‘support’ arg. If you don’t want the editor, it is currently better to use the WPAlchemy ‘hide_editor’ option (http://www.farinspace.com/wpalchemy-metabox/#display_options).

    Hope this saves some one else some time.

  8. Ed

    Hi Dimas,

    I have the same question as Pietro above, could you post the metabox.php file that goes with the MediaAccess.php code, because it looks great, but I have no idea how to make this functionality work as shown in the video without that code that shows in the editor in the video.

    Thanks!

  9. Jesse

    I’m going to use this for creating a list of slides to use in a slide show on a home page of a wp site. The add / remove option to clone the fieldset is a godsend but I’m wondering how hard it would be to implement some jquery that lets us grab a fieldset instance and drag it up or down – maybe even arrows to click up to move it up in the list of images in order to change the order or fieldset instance number.

    Also wondering if there is a way to limit or set max amount of times something can be cloned. For instance I want the user to be able to add anywhere from 1 to 5 max images for the slideshow but it looks like you can add an infinite amount right now all the way down to none at all.

    Maybe these are feature requests as I’ve seen jquery to allow reordering of fieldset objects but not sure how to use that with the way this class is currently programmed.

  10. Jesse

    Dimas, thanks a bunch! I got them both working exactly like your examples.

    I know this is a work in progress (the media class) but I tried copying the text from the videos for this to my meta box but I get object errors so it’s maybe something to do with the videos being hard to decipher. An example template with the media upload button like your example in the video is what I’m looking for.

  11. alanna

    great work, thanks! works very well.

  12. Jesse

    I didn’t declare a new instance of WPAlchemy_MediaAccess() in my functions file. Works now.

  13. Duong

    Hi Dimas: i can’t find repeating_fields_meta.php and custom_meta.php in https://github.com/farinspace/wpalchemy/blob/dev/wp-content/wpalchemy/ please give me two files. Thanks you!

  14. shawn

    @Dimas

    Any chance you have the time to take a look at my comment from a few months ago?
    http://www.farinspace.com/wordpress-media-uploader-integration/#comment-14671

    I’d still like to see how to get the actual thumbs to show up for images instead of the links. Combine that with the sortable, and my gallery is gonna be so much better than it is now.

    thanks
    *everything else works perfectly, love the class and use it all the time

  15. Ma'moun

    It would be useful if we could also specify a default size for the image.

  16. Ma'moun

    Actually, returning the attachement ID would be so helpful. It’s even far more flexible than getting the image URL. (e.g. it can be used to get different sizes in the front-end template)

  17. Ma'moun

    @Dimas Any chance you can add the ability to get the file attachment IDs to MediaAccess Class?

  18. Fabien

    Thanks for that videos, it helps very much !

    Keep going ;-)

  19. kathy

    hi dimas- do you think you can put up a gist or paste the code you are using in your metabox template to get this to work. it is a bit tough to see in the video

  20. kathy

    thanks dimas! i think it’d be much neater to have that folded into alchemy for me, but i’ve patched together something that i use all the time now though. it uploads, stores the url, attachment id and i think it tries to catch alt text too, pulls in a preview, and adds a delete button. the delete button removes the preview image and clears all those hidden fields. maybe you can make use of it if you ever get spare time for this again. you know, b/c i’m sure you have tons of that. ;)

    http://pastebin.com/kigpvmzq

    nb: i have a constant WPALCHEMY which is defined elsewhere as just the URL to my alchemy folder

  21. Melinda

    @kathy
    Thanks for sharing your code! It helped me to pull the image into my metabox that shows the user which image they uploaded, instead of just the image url. What I really want to do is pull the thumbnail of that image into the metabox instead of the full size image. Do you have any idea how to do this?

    Thanks!

Leave a Reply