Move media files from the root to date folder structure

Normally, WordPress stores all your images and other media files in the /wp-content/uploads/ folder. To keep it structured, all files are stored in folders organized by year and month. The problem you will run into with reorganizing them is that links to the files in posts and pages will not update if you are simply … Read more

WordPress media upload issue could not insert attachment into the database

Try the following solutins: First of all check your WP database size and check whether the size is full according to your hosting provider’s requirement/rule. Second option, add this line into your wp-config.php: define(‘WP_MEMORY_LIMIT’, ‘256M’); Also if you have access to php.ini (or php[version number].ini) file on your server, try to add this line: memory_limit … Read more

Flat media folder vs multiple directories

I recently took over a website that uses a flat media folder in the site root. Is there a benefit to that over using the standard WordPress media folder structure of uploads/year/month/file? Not particularly, mostly preference. Some people might do it thinking it enhances SEO, but I’ve seen no evidence to support that claim. My … Read more

Unable to upload file more than 1MB in size

Upon debugging we found the wp_max_upload_size function was returning 1MB. The u_bytes and p_bytes were as expected and equal to 100MB as defined in our uploads.ini file but the application of upload_size_limit filter changed the size to 1MB i.e., the problem was at: return apply_filters( ‘upload_size_limit’, min( $u_bytes, $p_bytes ), $u_bytes, $p_bytes ); A upload_size_limit_filter … Read more

How to redirect Webp files?

If I’m reading it right, your regex has only two items in (), which means that only $1 and $2 have any meaning. I copied your sample text and went to https://regex101.com/ (note: this is not an endorsement) to try to assemble a regex that’ll cover all your images. Here’s what I ended up with: … Read more

Upload multiple files in randomly generated folder using wp_upload_bits

Apply the following fixes (those with the // Fix <number>: comment) and your code would work in that only one random folder that will be created for all the uploads in the current session: (Note: I presumed the $countfiles is properly defined in your actual code.) function file_upload_callback() { global $wpdb; $table_name=”wp_order_quotes_real”; $_filter = true; … Read more