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="https://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="https://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