Using Add from Server to upload by post ID

You can try to add this into your functions.php file: add_filter( ‘upload_dir’,’wpse87234_upload_dir’); function wpse87234_upload_dir($uploads){ // check if we are in the “Add From Server” media tab if (isset($_REQUEST[‘post_id’]) && isset($_GET[‘tab’]) && $_GET[‘tab’]==”server”) { $prefix=”post_”; $post_id=(int)$_REQUEST[‘post_id’]; // change the uploads info to our needs: $uploads[‘subdir’]=”https://wordpress.stackexchange.com/”.$prefix.$post_id; $uploads[‘path’]=$uploads[‘basedir’].$uploads[‘subdir’]; $uploads[‘url’]=$uploads[‘baseurl’].$uploads[‘subdir’]; } return $uploads; } This should give directory like … Read more

Where to set individual blog quotas?

Go to your site’s Network Admin page — usually something like example.com/wp-admin/network/. Go to Sites » All Sites. Mouse over the site that you need to edit and select Edit in the menu that appears. Now select the Settings tab. Scroll down to the bottom (or near the bottom, depending on whether you have plugins … Read more

Check for file extension or mime type fails

Found where I made the error, on the condition, my code was: if ($filetype[‘type’] != $fileCSV || $filetype[‘type’] != $fileText) { echo “Error, the file $filename has not a valid extension: ” . $filetype[“ext”]; continue; } And the right is this one: if (!in_array($filetype[‘type’], array($fileCSV, $fileText))) { echo “Error, the file $filename has not a … Read more

tb_show not showing a media upload window . custom plugin

I couldn’t find what was wrong with the code, so I used a different code which I found on the internet and now the window is opening. var file_frame; $(‘#csv_file_button’).on(‘click’, function(event){ event.preventDefault(); if ( file_frame ) { file_frame.open(); return; } // Create the media frame. file_frame = wp.media.frames.file_frame = wp.media({ title: $( this ).data( ‘File … Read more

Maximum post size?

Try editing the post_max_size variable, if you have access to your php.ini file. This variable is the limit of the entire body of the request, which could include multiple files (source – stackoverflow). If you don’t have access to it you can try editing your functions.php file and add: @ini_set( ‘post_max_size’, ’64M’); //this will set … Read more

User permissions to upload images

Only logged in user can upload media from front end. Below code will allow users to see only their media files and not others. Put this in your theme’s functions.php file. I hope this helps. add_action( ‘pre_get_posts’, ‘users_own_attachments’); function users_own_attachments( $wp_query_obj ) { global $current_user, $pagenow; if ( $pagenow == ‘upload.php’ || ( $pagenow == … Read more