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.

So I have run into a little glitch. i have a custom path for uploads and it works. the files get saved to the right place, etc. The problem I have is the 'widget box' in the admin section. immediately after uploading and setting the uploaded image as the featured image, it show up in the preview, instead of www.blog.com/blog/uploads/POST_ID/image_name.png it is showing

www.blog.com/blog/uploads/image_name.png The path is broken. Again I am new to WP... is there a filter for the admin 'widget box's?

The path I get back is: <img width="266" height="145" src="http://mysite.com/blog/wp-content/uploads/image-350x192.png" class="attachment-266x266" alt="the title" title="the title">

But where the image resides is: <img width="266" height="145" src="http://mysite.com/blog/wp-content/uploads/<POST_ID>/image-350x192.png" class="attachment-266x266" alt="the title" title="the title">

I cant add an image because of my rep so far... it appears in the same column as tags and categories in the admin area. It is a custom widget for this theme.

update

    function media_upload_dir($upload) {
        if(!isset($_REQUEST['post_id']))
        return $upload;
$id = $_REQUEST['post_id'];
        if (isset($_REQUEST['post_id'])) {
            $upload['path']    = "/path/www/blog/wp-content/uploads/" . $id;
            $upload['url']     = "http://site.com/blog/wp-content/uploads/" . $id;
            $upload['basedir'] = "/path/www/blog/wp-content/uploads/" . $id;
            $upload['baseurl'] = "http://site.com/blog/wp-content/uploads/" . $id;
            if (!file_exists("/path/www/blog/wp-content/uploads/" . $id)) {
                mkdir("/path/www/blog/wp-content/uploads/" . $id, 0777);
            }
        }
        return $upload;
    }
    add_filter('upload_dir', 'media_upload_dir');

cheers.bo

share|improve this question
    
What do you refer as the "widgets box"? Is it the Featured Image box? A screenshot could be useful. Also, is this path being printed or you see it when inspecting the html code? –  brasofilo May 28 '12 at 16:22
    
yes the featured image! –  roberthuttinger May 30 '12 at 14:04
    
But you can post a link to some screenshots somewhere else... What about the path, how are you checking it? –  brasofilo May 30 '12 at 14:49
    
i added the path above. using firebug –  roberthuttinger May 30 '12 at 14:52
    
How are you setting the custom upload paths? Your custom widget may need to be adapted accordingly. –  MathSmath May 30 '12 at 18:15
show 4 more comments

1 Answer

This is not a answer, is an extended comment with the link to the solution.

First, while testing, one of my test sites wasn't showing the Featured Image uploaded to the folder /wp-content/uploads/POST_ID/image_name.jpg. Same problem as the OP.

But, it was not displaying any path to the image. And the bug was that the installation where I was testing is full of hacks (my main WPSE testing base). As soon as I went to a stable installation everything worked.

So, if your problem persist, do a full troubleshooting:
http://wordpress.org/support/topic/troubleshooting-wordpress-33-master-list

Also, Robert, when asking a question please provide all the elements that a person who is willing to help will need to understand and effectively answer it.

Side notes to your code:

Best regards and good luck!

share|improve this answer
add comment

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.