Is there a way to delete images from the Media Library programatically?
Use wp_delete_attachment <?php wp_delete_attachment( $attachment_id ); ?>
Use wp_delete_attachment <?php wp_delete_attachment( $attachment_id ); ?>
Media items are just like posts with post_type = attachment and post_status = inherit. when we are on upload.php page, we have two views: List View Grid View Grid view is populated via JavaScript and list view is extending normal WP_List_Table. Since it (List view) is using normal post query we can use pre_get_posts to … Read more
To let the current users only view his/her uploaded attachments, add the following code to your themes actions: add_filter( ‘posts_where’, ‘devplus_wpquery_where’ ); function devplus_wpquery_where( $where ){ global $current_user; if( is_user_logged_in() ){ // logged in user, but are we viewing the library? if( isset( $_POST[‘action’] ) && ( $_POST[‘action’] == ‘query-attachments’ ) ){ // here you … Read more
I found the solution from here: https://stackoverflow.com/questions/13936080/pre-select-images-when-opening-wordpress-3-5-media-manager And it works. Here’s my modification and this is using a single-image select media frame: frame.on(‘open’, function(){ var selection = frame.state().get(‘selection’); var selected = $(‘#image-id’).val(); // the id of the image if (selected) { selection.add(wp.media.attachment(selected)); } });
Filter pictures in the media library [closed]
Best plugin to manage media library? [closed]
The answer is there is no damn hook for the edit button. It’s just a bunch of JS contained within wp-includes/js/tinymce/plugins/wpeditimage/plugin.js. I’ve included the barebones of what you need below. Key points: a. Clicking an element with a data-wp-imgselect attribute will open the image edit dialogue. You need to change that to something else if … Read more
I think separate language site is better in most case, until better auto-translation technology appear. MultiSite Language Switcher plugin is a good plugin for this purpose. Media can be linked by url, you can even use external/dedicated site for storage block. If necessary, and there’s no main storage limitations simply create rsync cron to copy … Read more
Images dont show in grid view, but do in list view
Customize WordPress Media Manager – Media Window