Edit image / Delete image link

This isn’t 100% complete, but should be a good start for you. <a href=”https://wordpress.stackexchange.com/questions/31371/<?php echo wp_nonce_url(“/wp-admin/post.php?action=delete&amp;post=$post->ID”, ‘delete-attachment_’ . $post->ID ) ?>”><?php _e( ‘Delete Permanently’ ) ?></a> A couple notes on what you’ll have left to do: This will do no confirmation, so you’ll probably want to use JS to verify that it wasn’t clicked by … Read more

Remove duplicate attachments

function get_attachment_files(){ $args = array( ‘post_type’ => ‘attachment’, ‘numberposts’ => -1, ‘post_status’ => null, ‘post_parent’ => 0 ); $attachments = get_posts($args); if ($attachments) { foreach ($attachments as $post) { setup_postdata($post); wp_delete_post( $post->ID ); } } } add_action(‘admin_init’,’get_attachment_files’); adapted from: http://wpsnipp.com/index.php/functions-php/list-all-unattached-files-in-media-library/ I’d be careful of this though, because I am not sure it won’t delete the … Read more

complex restriction of items in media library

Good code. I think you could simplify by making direct SQL queries instead: — Featured Images SELECT `meta_value` FROM `wp_postmeta` WHERE `meta_key` = ‘_thumbnail_id’; –> $thumbnail_ids — Header Images SELECT `post_id` FROM `wp_postmeta` WHERE `meta_key` = ‘_wp_attachment_context’ and `meta_value` = ‘custom-header’; –> $header_ids Also, with your method, I think that if you call WP_Query with … Read more

Validate alt text for attachments?

The code below will only run once whenever a file is uploaded. We keep an array ( $image_mimes ) of acceptable image-mimetypes We get the current attachment mime type We make sure what is given is indeed an image ( because we don’t need unnecessary postmeta cluttering our table ) We grab the title from … Read more

How can I UN-attach media from a post?

I learned from Brian Fegter that you can Un-attach an image from a post while participating in this question: Can I attach an image to a different post? It isn’t exactly “simple”, but not to difficult. It’s the only solution I’ve been able to find.

get_the_post_thumbnail() doesn’t taking style attribute

get_the_post_thumbnail attribute array doesn’t know STYLE , the fields that are available for you to use are: src class alt title so just use the class and define you class to it: $attr = array( ‘title’ => get_the_title(), ‘alt’ => get_the_title(), ‘class’ => ‘rss_thumb’ ); $thumb = get_the_post_thumbnail($post->ID, ‘large-thumb’, $attr); and then define the style … Read more

Trying to hide buttons from Attachment window

Jose, give this a shot and see if that’s the kind of thing you had in mind.. EDIT: Done a little bit of testing and copying of core code to archieve this, but i think the new example i’ve added below should do what you’ve described, remove the buttons, “Insert into Post”, etc…, but keep … Read more

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