I have a function that sideloads a YouTube thumbnail onto a page… but I want to remove the featured thumb on the page first (and remove all the various auto-generated sizes, too).
I’m assuming I want to use delete_post_thumbnail()
followed by wp_delete_attachment()
to un-associated the thumb from the post, and then kill the thumb file. Is that correct? And Will that also delete all the various thumb media files (the extra auto-generated sizes) from the disk?
Using
wp_delete_attachment( $attachmentid, true )
is only thing you need.Passing
true
as second argument, ($force_delete
see codex ) it:So you do not need to also use
delete_post_thumbnail()
.