Delete all thumbnails for a post

Using wp_delete_attachment( $attachmentid, true ) is only thing you need. Passing true as second argument, ($force_delete see codex ) it: remove the thumbnail association with any post delete any taxonomy associated to attachment and of course remove all the files, also the autogenerated ones So you do not need to also use delete_post_thumbnail().

How do I get a random image from subset of images in media gallery?

You can use taxonomies with the media library, you just need to either add a built-in taxonomy, or register a new one. For example, adding the built-in post tag taxonomy to attachments: function wpd_attachment_taxonomy() { register_taxonomy_for_object_type( ‘post_tag’, ‘attachment’ ); } add_action( ‘init’, ‘wpd_attachment_taxonomy’ ); You can then query for images with a specific tag: $args … Read more

Possible to swap in a placeholder image globally for the_post_thumbnail_url if one doesn’t exist?

If you know the URL of the placeholder image, you sure can do it. get_the_post_thumbnail_url() function calls the wp_get_attachment_image_url() function which in turns calls the wp_get_attachment_image_src() function to get the source of the post thumbnail. wp_get_attachment_url() returns the result from wp_get_attachment_image_src filter. So we can use that filter to modify the result if there is … Read more

add_image_size and add_filter(‘image_size_names_choose’, ‘my_custom_image_sizes’) not working with wordpress 3.5.2

I’m running WordPress 3.5.2. The following is an excerpt from my functions.php file, which correctly allows me to select a thumbnail size when I upload an image. // Basic setup for thumbnail support. function themeSetup() { add_theme_support(‘post-thumbnails’); add_image_size(‘tiny’, 128, 79); add_image_size(‘small’, 256, 158); add_image_size(‘medium’, 384, 237); add_image_size(‘large’, 512, 316); } add_action(‘after_setup_theme’, ‘themeSetup’); // Addes custom … Read more

Filter For Featured Image

The post featured image ID is stored as post metadata, so I would recommend hooking into the update_post_meta or update_post_metadata hooks, and then query the post meta for ‘_thumbnail_id’ being set. See this related answer from Jan Fabry.

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