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

Update media library attachments

edit: ok after working on this for the last hour ive finally found a solution that works without affecting uploading and without messing with ignore or reset wp.media.frame.on(‘open’, function() { if (wp.media.frame.content.get() !== null) { // this forces a refresh of the content wp.media.frame.content.get().collection._requery(true); // optional: reset selection wp.media.frame.content.get().options.selection.reset(); } }, this);

Media Library Latency, Lag, CRON?

When I add images to my Media Library they aren’t available in the Media Library for about an hour. It seems like there is a queue or some sort of CRON that fires. WordPress handles uploads immediately, there is no latency, queues, or cron unless you introduce one yourself. The image appears in the media … Read more