How to save media files under “http://example.com/custom_folder” for a specific page

Try this add_filter(‘upload_dir’, ‘upload_image_specific_calback’); function upload_image_specific_calback( $param ){ //$_GET[‘post’] which is your target post like 10 is post id. //After click update button. if(isset($_GET[‘post’])){ if($_GET[‘post’] == 10){ $param = array( ‘path’ => get_home_path().’logos’, ‘url’ => home_url().’/logos’, ‘subdir’ => ”, ‘basedir’ => get_home_path(), ‘baseurl’ => home_url(), ‘error’ => false ); } } //$_POST[‘post_id’] which is your … Read more

Delete images uploaded by ‘Subscriber’ role

Here’s some code which pulls all subscriber IDs, then pulls all attachments from those subscribers and attempts to delete them. If it can’t delete them it’ll write to the error log letting you know. $subscribers = get_users( array( ‘role’ => ‘subscriber’, ‘fields’=> ‘ID’, ) ); if( ! empty( $subscribers ) ) { $files = new … Read more

This file type is not allowed. Please try another

Original Answer Add the code below to your current theme’s functions.php: function wpse_add_nb_mime_type( $allowed_mimes ) { $allowed_mimes[‘nb’] = ‘application/mathematica’; return $allowed_mimes; } add_filter( ‘mime_types’, ‘wpse_add_nb_mime_type’, 10, 1 ); Remove define, mentioned in your question, from wp-config.php. Now you should be able to upload .nb files. Plugin alternative: to make the code above, immune to theme … Read more

how to upload mp3 from url to wp media

As @fuxia suggest, You have to extend $wp_filetype check for mp3 also. for mp3 extenstion you can use audio/mpeg3, audio/x-mpeg-3, video/mpeg, video/x-mpeg mime types. just add check condition in try block where you check for image valid type. I have tested and it is working fine for me. let me know if this helps to … Read more

show image in mail contact form 7 [closed]

As per my comments, it seems you are trying to attach images to emails rather than ‘show’ them. Since you have [file* image filetypes:jpg|png|gif] what you need to do is put [image] in the ‘File Attachments’ box in the Contact Form 7 settings. This is from the Contact Form 7 File Uploading and Attachment doc.

How to validate the file name of the Media File Uploads?

The filter is sanitize_file_name. You get the $filename as parameter. Sample code: add_filter( ‘sanitize_file_name’, ‘wpse_77892_filter_filename’ ); function wpse_77892_filter_filename( $filename ) { return str_replace( ‘%’, ‘-‘, $filename ); } See my plugin Germanix URL for an extended example.

Rename image uploads with width in filename

I’ve managed to do it with the filter image_make_intermediate_size. Probably all the path/filename.extension dismembering and remaking could be optimized or made in a single stroke fashion, but alas, I’ll let that to the reader: // The filter runs when resizing an image to make a thumbnail or intermediate size. add_filter( ‘image_make_intermediate_size’, ‘rename_intermediates_wpse_82193’ ); function rename_intermediates_wpse_82193( … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)