How can I bulk delete media and attachments using WP-CLI?
From the WP-CLI documentation about wp post delete: wp post delete –force $(wp post list –post_type=”attachment” –format=ids) See wp post list for additional information.
From the WP-CLI documentation about wp post delete: wp post delete –force $(wp post list –post_type=”attachment” –format=ids) See wp post list for additional information.
First, it is important to consider why you are restricting access to wp-admin. If you are doing this mainly for aesthetic purposes, then the solution provided below is fine. However, if you are doing it because you don’t want your users to be able to perform certain functions provided via the back-end, you should be … Read more
I have tested this with an image I created myself with Photoshop where I inserted the word “Süss” in every thinkable IPTC field. I uploaded it to my WordPress 4.6 installation, which has no image handling plugins installed. The uploading went smoothly, the right thumbnails were created in the uploads directory and the caption field … Read more
it’s a longshot but, add_attachment hook, actually fires after the first file finished uploading: add_action(‘add_attachment’,’redirect_uploader_flow’); i’m using it to load a custom interface for resizing a Image loading in the current TB window: jQuery(“#TB_iframeContent”,window.parent.document).attr(‘src’,”<?php echo get_window_url($id) ?>”); the main problem is that it will break multiple file uploads
You can debug the result of attachment by : console.log(attachment); and if the thumbnail size available you can retrieve it using : var thumb = attachment.sizes.thumbnail.url; alert(thumb);
I presume you’ve fixed this already but (in a blatant attempt to snaffle the bounty and) as mentioned in the comments there’s a simple fix, in your myplugin_meta_box_callback() function change the line $mime_types = array( ‘application/pdf’ ); to $mime_types=”application/pdf”; The library.type option to wp.media expects a string (which can be comma-separated with additional types) not … Read more
I have checked your code, and I think you are missing the guid of the images. Please have a look at the code below: $post_id = 1234; $images = array(‘filename1.png’, ‘filename2.png’, … ‘filename10.png’); // Get the path to the upload directory. $wp_upload_dir = wp_upload_dir(); foreach($images as $name) { $attachment = array( ‘guid’=> $wp_upload_dir[‘url’] . “https://wordpress.stackexchange.com/” … Read more
This block of code will add a button right next to the “Insert into post” one. When clicked, it will send selected images to WP editor, each wrapped inside your template HTML: var wpMediaFramePost = wp.media.view.MediaFrame.Post; wp.media.view.MediaFrame.Post = wpMediaFramePost.extend( { mainInsertToolbar: function( view ) { “use strict”; wpMediaFramePost.prototype.mainInsertToolbar.call(this, view); var controller = this; this.selectionStatusToolbar( view … Read more
This works for me in order to list the items uploaded by a user on the media library. function users_my_media_only( $wp_query ) { if ( false !== strpos( $_SERVER[ ‘REQUEST_URI’ ], ‘/wp-admin/upload.php’ ) ) { $current_user = wp_get_current_user(); $current_user = $current_user->ID; if ( ! current_user_can( ‘manage_options’ ) ) { global $current_user; $wp_query->set( ‘author’, $current_user->id ); … Read more
Assuming that you’re providing upload functionality via WordPress’ native functions, lik wp_handle_upload or something more high-level, we come to the conclusion that several hooks are going to be pulled. http://core.trac.wordpress.org/browser/tags/3.3/wp-admin/includes/file.php#L212 The wp_handle_upload function would probably be the last native function to touch the file, and would know all the information that is necessary to keep … Read more