WordPress Media Manager 3.5 – default link to

You can do what you want by overriding appropriate Backbone view, which is responsible for rendering attachments display settings form. plugin.php add_action( ‘load-post.php’, ‘wpse8170_media_popup_init’ ); add_action( ‘load-post-new.php’, ‘wpse8170_media_popup_init’ ); function wpse8170_media_popup_init() { wp_enqueue_script( ‘wpse8170-media-manager’, plugins_url( ‘/js/media.js’, __FILE__ ), array( ‘media-editor’ ) ); } media.js (function() { var _AttachmentDisplay = wp.media.view.Settings.AttachmentDisplay; wp.media.view.Settings.AttachmentDisplay = _AttachmentDisplay.extend({ render: function() … Read more

What’s the proper way to find and remove duplicate images from posts and the media library?

combining the two answer on this page, I found this worked. $args = new WP_Query(array( ‘post_type’ => ‘post’, ‘posts_per_page’ => -1 )); $loop = new WP_Query($args); while($loop->have_posts()) { the_post(); $args2 = array( ‘order’ => ‘ASC’, ‘post_type’ => ‘attachment’, ‘post_parent’ => $post->ID, ‘post_mime_type’ => ‘image’); $attachments = get_posts($args2); if($attachments) { foreach ($attachments as $img_post) { if( … Read more

How can I batch delete all unattached images with WP-CLI or other automated process?

You can try this (untested) modification to the answer you linked to by @something wp post delete $(wp post list –post_type=”attachment” –format=ids –post_parent=0) to delete attachments without parents. To target a given mime type, e.g. image/jpeg try: wp post delete $(wp post list –post_type=”attachment” \ –format=ids –post_parent=0 –post_mime_type=”image/jpeg”) Notes: Remember to backup first before testing! … Read more

Disable Media Uploads to non Admin Users

Here are 2 methods: Method 1: Remove the upload_files capability from the respective roles. e.g. removing it from author: $role = get_role( ‘author’ ); $role->remove_cap( ‘upload_files’ ); This is saved to the database so it should only happen once, not on every page load. Removing it from the editor role should be the same albeit … Read more

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