wrong media url in wordpress
wrong media url in wordpress
wrong media url in wordpress
Resolved in a completely different way. Googled this, so technically not my own answer, but does the job: // ACF upload prefilter function gist_acf_upload_dir_prefilter($errors, $file, $field) { // This filter changes directory just for item being uploaded add_filter(‘upload_dir’, ‘gist_acf_upload_dir’); } // ACF hook, set to field key of your file upload field add_filter(‘acf/upload_prefilter/key=field_5b2b0326ea0e1’, ‘gist_acf_upload_dir_prefilter’); // … Read more
You can use sanitize_file_name hook for this. function my_sanitize_file_name( $filename ) { $chars_table = array( ‘ ‘ => ‘_’, ‘-‘ => ‘_’, ); $friendly_filename = preg_replace( array_keys( $chars_table ), array_values( $chars_table ), $filename ); return strtolower( $friendly_filename ); } add_filter( ‘sanitize_file_name’, ‘my_sanitize_file_name’, 10 ); It will also convert letters to lowercase to avoid conflicts on … Read more
This may due to the SELinux feature of the Fedora OS. You can temporarily disable the SELinux in Fedora as follows and test. Check SELinux status as sestatus If the SELinux is active, the result for the above command will be included. Current mode: enforcing Execute command sudo setenforce 0 to temporarily disable SELinux Then … Read more
WordPress 4.9.8 Trying to add filename over image in Media Browser
Stop WordPress from generating redundant image size
This is example for only doc file for admin. You are also add another file to avoid restriction for admin. add_filter( ‘wp_check_filetype_and_ext’, ‘file_and_ext_allow_for_user’, 10, 4 ); function file_and_ext_allow_for_user( $types, $file, $filename, $mimes ) { if( is_admin() ){ if( false !== strpos( $filename, ‘.doc’ ) ) { $types[‘ext’] = ‘doc’; $types[‘type’] = ‘application/msword’; } } return … Read more
The uploaded file could not be moved to wp-content/uploads/2019/07
Oh, well, while writing the question I tried to copy the full link that takes the ajax call: example.com/wp-admin/async-upload.php and noticed that for the subscibers it was taking the user to their account page while the admins where getting The link you followed has expired. Notice on the screen. And then I got the ‘Aha’ … Read more
move_uploaded_file() not working on wordpress front end