plugin-icon

Post Media Cleanup

لصاحبه iftiarhossain·
Automatically deletes all associated media files when a post is permanently deleted.
النسخة
1.0.0
آخر تحديث
Jul 13, 2026

Post Media Cleanup removes orphaned media files from your server when you permanently delete a post.

When you permanently delete a post, this plugin automatically finds and removes:

  • Featured image
  • Images and files embedded in post content
  • PDFs and any linked files in content
  • All attachments uploaded directly to the post

Key Features

  • Only fires on permanent deletion — moving to trash is always safe
  • Skip Shared Media — never deletes a file used by another post
  • Works per post type — configure exactly which types trigger cleanup
  • Compatible with S3 and cloud storage
  • Multisite ready
  • Developer friendly — filter hooks to extend behaviour

For Developers

Add extra attachments to the deletion list:

add_filter( 'postmediaweb_attachment_ids_to_delete', function( $ids, $post_id ) { $extra = get_post_meta( $post_id, 'my_custom_pdf', true ); if ( $extra ) $ids[] = (int) $extra; return $ids; }, 10, 2 );

Prevent a specific attachment from being deleted:

add_filter( 'postmediaweb_should_delete_attachment', function( $should, $att_id, $post_id ) { if ( $att_id === 999 ) return false; return $should; }, 10, 3 );
مجانيعلى الخطط المدفوعة
إذا أتممت بالتثبيت، فإنك توافق على شروط خدمة ووردبريس.كوم ووشروط إضافات الأطراف الثالثة.
تم اختباره حتى
WordPress 7.0.1
تتوفّر هذه الإضافة للتنزيل لتُستخدم في عملية التثبيت لديك.