Deleting images from R2
-
I have linked a page; this image was deleted about 24 hours ago from WordPress. All images are hosted on R2.
Whenever a post is deleted and emptied from trash, I run thisadd_action( 'before_delete_post', 'delete_all_attached_media' );
function delete_all_attached_media( $post_id ) {
if( get_post_type($post_id) == "listing" ) {
$attachments = get_attached_media( '', $post_id );
foreach ($attachments as $attachment) {
wp_delete_attachment( $attachment->ID, true );
}
}
}The images from Media Library are deleted fine but I have noticed that they are not being deleted from R2. All my images offloaded.
I am attaching a screenshot of my settings as well (if the image does not load: check it here: https://postimg.cc/fVRHj74K)
The image that has been deleted from Media Library but still exists on R2: https://assets.localgofer.co.nz/2026/05/localgofer_co_nz_20260522_141734_5551.jpgWill appreciate any help.
Thanks
The page I need help with: [log in to see the link]
You must be logged in to reply to this topic.