Uploads going to the root of wp-content/uploads

What else to check? First, deactivate all plugins and switch to a different theme. Then test uploads. If its fixed reactivate plugins/theme one at a time until you find the culprit. Next, you can check the database options table to see if the upload_path or upload_url_path have been altered, they should be blank. Then, you … Read more

Big file upload give HTTP error

That issue is not due to WordPress but due to your server configuration. Try increasing the PHP memory on the server as well as the max upload filesize. If you do not know how to do that please contact your hosting provider. Each server is different for that configuration therefore you won’t be able to … Read more

get array of files in uploads dir

You should also check if that dir exists and loop through the list_files if they exist. Since you asked for another idea to get those files: You can use the php function glob. It finds pathnames matching a pattern. You can find the Glob PHP manual here. $current_user = wp_get_current_user(); $upload_dir = wp_upload_dir(); $user_dirname = … Read more

get_template_directory_uri() generates wrong path

Do your URL change up in phpMyAdmin with SQL language: # Change website url UPDATE wp_options SET option_value = replace(option_value, ‘http://www.old-site.com’,’http://www.new-site.com’) WHERE option_name=”home” OR option_name=”siteurl”; # Change GUID URL UPDATE wp_posts SET guid = REPLACE (guid, ‘http://www.old-site.com’,’http://www.new-site.com’); # Change url of medias, post, page, etc. UPDATE wp_posts SET post_content = REPLACE (post_content, ‘http://www.old-site.com’,’http://www.new-site.com’); # Change … Read more

Correctly using the root directory for media uploads?

The WordPress uploads directory’s path and URL are determined by the wp_upload_dir() function which applies a filter named upload_dir which you can use to fix the double slashes in the attachment URL. So if you turned off the “Organize my uploads into month- and year-based folders” setting, try the following: add_filter( ‘upload_dir’, function ( $data … Read more

Change Image folder Locations

The GUID is not the image’s URL. It typically does end up (coincidentally) being the original URL of the image, because it needs to be a unique identifier – but that’s all WordPress uses it for, as a unique identifier. Your code should successfully update the URLs of the featured images of posts, but only … Read more

Moving Existing images from custom directory to WP’s upload directory

Thanks for the response @jxxe. So I ended up figuring out how to do what I needed to do. For anyone else who might be needing the same thing, here’s what I did. Downloaded /assets/ directory via SFTP Commented out define(‘UPLOADS’, ‘assets’); in wp-config.php Uploaded contents of assets to /wp-content/uploads/ via SFTP Surprisingly, I didn’t … Read more

Set different max upload size limits based on file type/extension

This should work: function max_video_size( $file ) { $size = $file[‘size’]; $size = $size / 1024; $type = $file[‘type’]; $is_image = strpos( $type, ‘video’ ) !== false; $limit = 750; $limit_output=”750kb”; if ( $is_image && $size > $limit ) { $file[‘error’] = ‘Video files must be smaller than ‘ . $limit_output; } return $file; } … Read more