Capability to prevent upload of files

You can try with this: function remove_media_tabs($strings) { unset($strings[“insertFromUrlTitle”]); unset($strings[“setFeaturedImageTitle”]); unset($strings[“createGalleryTitle”]); unset($strings[“uploadFilesTitle”]); return $strings; } add_filter(‘media_view_strings’,’remove_media_tabs’); This will remove ‘Upload file’ and ‘Insert from URL’ links when you open insert media screen, so user will be able only to select images or whatever that is already in media library. For more things you can do … Read more

media_handle_sideload on a file already on server

I solved this by simulating a $_FILES array: $file_array = array( ‘name’ => basename( $file_path ), ‘type’ => $url_type, ‘tmp_name’ => $file_path, ‘error’ => 0, ‘size’ => filesize( $file_path ) ); And then $att_id = media_handle_sideload( $file_array, $post_id ); As simple as this..

Choosing images size when uploading

For trivia WP will generate all registered sizes for every image natively. While this doesn’t quite seem optimal, the recommendation (if one might call it that) to deal with it is “get bigger disks”. 🙂 If size isn’t a concern you can just go with it. The typical solution takes a little different angle. Instead … Read more

What are best practices to storing uploads in WordPress?

If you have a lot of uploads, using the /year/month/day/ approach is recommended in order to keep the number of files in each directory manageable. (Just today I ran into an issue where there were more files in the uploads folder [~12,000] than the FTP server was configured to include in a directory listing [~10,000]. … Read more

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