Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

Ok. Going to try and explain this as best as I can, so bare with me. Anyway, I'm trying to include the default media uploader as a part of my plugin.

Currently, I've successfully managed to use the filter attachment_fields_to_edit to hide most of the input fields, leaving only the title & alternate text fields, alongside a custom submit button. When clicked, this button gets the images URL and places it into a div on the parent page.

Anyway, so here is my problem. Everything regarding the uploader itself is functioning how I want it to, but currently the filter is applying itself to the media uploader in posts, pages, the media library, etc. I only want the alternative fields & custom button to show within my plugin, but not elsewhere.

I've tried everything, but I cannot get it to work. I managed to apply my own query to the media-upload.php URL, and that way I could make the alternative fields only show within my plugin on the thickbox 'library' tab, but when uploading a new image the default fields were showing because Wordpress uses an alternative file to upload the image; async-upload.php.

Here is the entire function: http://pastebin.com/5vpecMvL

Just some information on the various functions: riva_slider_pro_info() is a function that returns an array of values. riva_slider_pro_uri( $search ) gets $_SERVER[ 'REQUEST_URI' ] and stores it in a variable, search its for the $search parameter and return true or false.

In the 'libary' tab within the media uploader thickbox, it is returning true because I have passed a additional query onto the media-upload.php URL (for example, 'media-upload.php?post_id=0$slideshow=true&type=image&TB_iframe=1'). BUT, it is returning false after the user has just uploaded a new image within the same thickbox, because it uses the async-upload.php file instead. Not sure how I could pass the query onto this URL, if it would be possible to make it work that way.

I realise this may be hard to follow, but I've tried my best to explain it. I'm literally pulling my hair out over this one and spent a ridiculous amount of time trying to figure it out. Appreciate any comments or suggestions, or ideally a solution! Thanks in advance.

share|improve this question
    
did you ever figure out how to filter the fields in certain places but not in others? i've always hid the fields w/ jquery, but i like this idea much better –  helgatheviking Jan 7 '12 at 1:22

1 Answer 1

up vote 1 down vote accepted

what i ended up doing was launching the thickbox uploaded manually via a jquery click event. then with setInterval i was able to hide the pieces i wanted.

jQuery(document).ready(function($) {

  $('.specialclass').click(function() { 
       //get post id from somewhere (for me this was the row column
    string = $(this).parents('tr.type-portfolio').attr('id'); 
    if(/post-(\d+)/.exec(string)[1]) post_id = parseInt(/post-(\d+)/.exec(string)[1], 10);

    tbframe_interval = setInterval(function() {

       //remove url, alignment and size fields- auto set to null, none and full respectively                        
       $('#TB_iframeContent').contents().find('.url').hide().find('input').val('');
       $('#TB_iframeContent').contents().find('.align').hide().find('input:radio').filter('[value="none"]').attr('checked', true);
       $('#TB_iframeContent').contents().find('.image-size').hide().find('input:radio').filter('[value="full"]').attr('checked', true);

    }, 2000);

    if(post_id) tb_show('', 'media-upload.php?post_id='+post_id+'&type=image&tab=library&TB_iframe=true'); //tab sets the opened TB window to show library by default

    return false;
   });
});
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.