Changing the media library default tab

There’s a filter called media_upload_default_tab that you can use to do this. <?php add_filter(‘media_upload_default_tab’, ‘wpse74422_switch_tab’); function wpse74422_switch_tab($tab) { return ‘library’; } You can set the to be whatever — assuming the tab exists. The tab keys themselves are found in the functon media_upload_tabs. <?php /** * Defines the default media upload tabs * * @since … Read more

How to make custom bulk actions work on the media/upload page?

If you want to use your code, try this: If you want to check if the medias are attachments, you can try to use $_REQUEST[‘detached’] add_action( ‘load-upload.php’, ‘export_media_test’ ); function export_media_test() { if ( ! isset( $_REQUEST[‘action’] ) ) return; echo ‘Export Media’; if ( isset( $_REQUEST[‘detached’] ) ) { die( ‘No attachments’ ); } … 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

wp media regenerate unknown –image_size parameter

I was able to duplicate the issue when running WP-CLI version 1.1.0, but the command worked successfully when I updated to the nightly build using: wp cli update –nightly The –image-size parameter was added to wp-cli/media-command on April 13, 2017 after the current stable release of WP-CLI v1.1.0 on February 1, 2017. This feature is … 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

Hide old attachments from wp media library

You can adjust the attachment query in the media library popup, through the ajax_query_attachments_args filter. Here are two PHP 5.4+ examples: Example #1: Show only attachments that where uploaded during the last 24 hours: /** * Media Library popup * – Only display attachments uploaded during the last 24 hours: */ add_filter( ‘ajax_query_attachments_args’, function( $args … Read more

Creating a metabox to upload multiple images, Ignoring The Featured Image

Generally speaking, I would take the approach of querying for post attachments, but withhold the attachment that is the post thumbnail. WP provides a simple way of finding the post thumbnail ID with get_post_thumbnail_id (Codex Ref). To modify the code from the other post, I would add the following parameter to the $args array to … Read more

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