I want to wrap the filter below in a conditional that tests whether the user is uploading an image from the Media Manager (Admin > Media > Add New) and not from the post editor image upload routine.

Is it possible to tell? $pagenow in both cases appears to be the same...

//no extra thumbs
global $pagenow;
function ce4_no_thumbs($sizes){return array();}

Update: It does appear that there is a post_id on the querystring when upload is accessed from within a post and not when it is accessed via "media manager > add new", however, the following test passes in either case...

if ( is_admin() && !isset($_GET['post_id']) ) {
    /*This should not fire if user is uploading an image into a post, 
      since post_id is on the querystring. However, in my test
      its still getting through.*/


2 Answers 2


I answered this for you in the comments of your previous question.

...you can use the filter that @Backie suggested above (intermediate_image_sizes_advanced), and in the hooked function check for a field in the post collection named _wp_http_referer. It tells you where the upload request came from.

If _wp_http_referer contains "media-new.php", you can return an empty array (which will temporarily stop thumbnail generation, but won't actually change any thumbnail settings). Otherwise, return the $sizes array untouched.


function wpsx_7756_no_thumbnails($arr_sizes){

    if(stristr($_POST['_wp_http_referer'], 'media-new.php')) {
        return array();

    return $arr_sizes;



Let me know if this works.

Keep in mind that adding the filter while you're on the upload form won't do what you want--the form posts to a separate page that handles the upload, and it won't respect your filter.

  • @MathSmath: I've added it to functions.php and tested. Unfortunately, all thumbs are still getting created when using "Media > Add New". Any ideas for trace testing? echo "the post referrer: ".$_POST['_wp_http_referer']; (returns an integer incremented by +1 each time an upload occurs)
    – Scott B
    Jan 26, 2011 at 0:25
  • Perhaps another option would be to test for iframe? It appears in the post uploader, but apparently not in the media manager > add new uploader.
    – Scott B
    Jan 26, 2011 at 0:33
  • @Scott B Dammit! I was sure that'd work :) Not sure about the iframe thing. To trace, I'd try adding a wp_die(json_encode($_POST)) to the beginning of your "no thumbnails" function. It'll dump the contents of the post collection at the time the filter is run. It's possible that by the time Wordpress gets around to actually making the thumbnails, the original post collection is out of scope? In any event, you might see something in the available post collection you CAN use to identify the referrer.
    – MathSmath
    Jan 26, 2011 at 1:07
  • @MAthSmath: Got It! if(!stristr($_POST['type'], 'image')) {return array();}return $arr_sizes;}
    – Scott B
    Jan 26, 2011 at 2:46
  • @ScottB AWESOME! Glad you got it working.
    – MathSmath
    Jan 26, 2011 at 3:35

Can you try $_GET['post'] instead of using $_GET['post_id'] ?

That's the request parameter I see.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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