How to Reduce the Maximum Upload File Size?

You can forbid uploads of a specific size (or for other reasons) in the wp_handle_upload_prefilter hook that is used in the wp_handle_upload() function. It get’s the file array passed, it’s a single item in the PHP standard superglobal $_FILES one that is documented in the PHP Manual: POST method uploads. Just create a function and … Read more

Multisite, upload images directly to Amazon S3

If you are running on a dedicated linux server and are comfortable with the command line, you could install s3fs. This is a program that allows you to actually mount your Amazon s3 Bucket as a directory on you server. In the standard multisite environment, media uploads for all sites but the main site are … Read more

There’s a way to scale media (images) at 50%?

You can use image_downsize filter and to catch when WordPress wants a downscaled image and not original, and actually a size what doesn’t exist. add_filter( ‘image_downsize’, ‘wpse_60890_retina_scale’, 10, 3 ); function wpse_60890_retina_scale( $value, $id, $size ) { if ( $size == ‘wpse_60890_retina_scaled’ ) { if ( !is_array( $imagedata = wp_get_attachment_metadata( $id ) ) ) return … Read more

Refresh wp.media after ajax call

So, I followed your links and this is working for me. This test works the same for my upload callbacks so hopefully it works for you. In the iframe function myTab_save_frame() { global $redir_tab; $redir_tab = ‘mytab’; media_upload_header(); ?> <button>Test Trigger</button> <script> var switchAndReload = function() { // get wp outside iframe var wp = … Read more

can not upload file .vtt on wordpress 5.0.1

I did some debugging and was able to reproduce and solve the issue, but unfortunately I was not able to figure out the specific cause. Generally speaking, it seems that .vtt files are failing the check performed by wp_check_filetype_and_ext(). I was able to upload .vtt files (Only tested on WP 5.0.1) after creating a simple … Read more

Set a maximum upload count for users on a specific user role

I’m not really sure which is the real problem with code you posted, however I cant understand why use 2 functions when one is enough… add_filter( ‘wp_handle_upload_prefilter’, ‘limit_uploads_for_user_roles’ ); function limit_uploads_for_user_roles( $file ) { $user = wp_get_current_user(); // add the role you want to limit in the array $limit_roles = array(‘contributor’); $filtered = apply_filters( ‘limit_uploads_for_roles’, … Read more

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