Change the filename format of saved featured images

There is a filter to use for the array containing the filename that is saved to postmeta but since there are no filters available to change the filename before it is saved you have to manually change it using rename(). function wpse_filter_image_resize_name( $filename ) { $new_name = preg_replace( “/-(?<match>\\d)/ui”, “_$1”, $filename ); if ( rename( … Read more

What might cause a POST to wp-admin/async-upload.php to return JSON >and< HTML?

I had the same issue and did not find any information in my debug output. It worked out, that DOING_AJAX was not defined (I don’t know why). Changing the beginning of async-upload.php from if ( isset( $_REQUEST[‘action’] ) && ‘upload-attachment’ === $_REQUEST[‘action’] ) { define( ‘DOING_AJAX’, true ); } to define( ‘DOING_AJAX’, true ); worked … Read more

Upload specific images to specific folder

In your answer you said that desired path is something like wp-content\uploads\state-name\destination\ where state-name is a taxonomy term and destination is the slug of one destination CPT. Last thing is not clear from your question, but it seems so, let me know if I’m wrong). So, I suggest you this workflow: Add a destination post … Read more

Where does wordpress store the FTP credentials?

It doesn’t. WP Filesystem API will ask for FTP credentials, but it will do so for each operation. They aren’t stored persistently. They can be stored persistently by hardcoding into wp-config.php, but WP won’t do that itself, it’s a user action. Note that WP only asks for FTP credentials if it cannot modify files without … Read more

How are the year and month folders added to the uploads directory?

This is how I understand the process: The wp_upload_dir() function is the main control room for the upload folder creation process and the wp_mkdir_p() function is the helpful assistant. Everytime wp_upload_dir() is called, it’s actually running a file_exists() check on the current upload folder, through the wp_mkdir_p() function. If the folder doesn’t exists it’s created … Read more