Search Media by taxonomy

To search, use the s option as described in the WP_Query documentation https://codex.wordpress.org/Class_Reference/WP_Query#Search_Parameter Search Parameter Show posts based on a keyword search. s (string) – Search keyword. Show Posts based on a keyword search Display posts that match the search term “keyword”: $query = new WP_Query( array( ‘s’ => ‘keyword’ ) ); Prepending a term … Read more

Delete Media not attached with Any posts

You can also do this direclty from your WordPress Dashboard. Login to your website and go to media for the same. In the media, select list view and filter the media which are Unattached to the post. Once you get the filtered media items, select all items and delete the same using Bulk Actions. The … Read more

Importing existing s3 Media into WP

In theory you’d think it could work like that. In reality, it doesn’t. There’s a simple reason no plugin exists that would do this. Whenever you import media into WordPress, it creates thumbnail files of various sizes, (even for videos). In order to create those thumbnails, it has to download (you guessed it) the entire … Read more

How to change the text of the “You are about to permanently delete these items…” alert message when deleting media from the media library?

You could use the gettext filter. See the examples here https://codex.wordpress.org/Plugin_API/Filter_Reference/gettext. In your filter you will add code to check IF it’s the exact text you want to change then if the users meta value is what you are looking for the return the revised text. Else return the passed text unchanged.

Auto delete pictures in media library by age

You can use these functions to find and delete image attachments that are 3 days old since their date of creation: // Delete attachments (images) that are {n} days old. function auto_delete_old_image_atts() { // How many days old. $days = 3; // TRUE = bypasses the trash and force deletion. $force_delete = true; // Get … Read more

How to disable (and hide) the Media Library for certain users?

I did a googles of the issue (using ‘wordpress restrict media access’) and got this link on the first page https://www.wpbeginner.com/plugins/how-to-restrict-media-library-access-to-users-own-uploads-in-wordpress/ Which has this code // Limit media library access add_filter( ‘ajax_query_attachments_args’, ‘wpb_show_current_user_attachments’ ); function wpb_show_current_user_attachments( $query ) { $user_id = get_current_user_id(); if ( $user_id && !current_user_can(‘activate_plugins’) && !current_user_can(‘edit_others_posts ‘) ) { $query[‘author’] = $user_id; … Read more

How to disable drag-and-drop upload function in Media Library?

Instead of removing upload script you can make the upload error out if the user does not have admin privileges. Like this- function tomjn_only_upload_for_admin( $file ) { if ( ! current_user_can( ‘manage_options’ ) ) { $file[‘error’] = ‘You can\’t upload images without admin privileges!’; } return $file; } add_filter( ‘wp_handle_upload_prefilter’, ‘tomjn_only_upload_for_admin’ ); For other possible … Read more

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