Commit c711280
committed
Media: Delete HEIC companion file when its attachment is deleted.
When the client-side media flow sideloads a HEIC original alongside a
JPEG derivative, the HEIC filename is stored in $metadata['original'].
wp_delete_attachment_files() only tracks 'original_image', so without
this hook the HEIC file would linger on disk after the attachment is
removed.
wp_delete_attachment_heic_companion_file() reads the meta key, guards
against non-string values (e.g. arrays written by other flows), and
deletes the file when present. Hooked into the delete_attachment
action via default-filters.php.
Backport of GB #76731, with the is_string() guard from GB #78128.1 parent b261f30 commit c711280
2 files changed
Lines changed: 40 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
562 | 562 | | |
563 | 563 | | |
564 | 564 | | |
| 565 | + | |
565 | 566 | | |
566 | 567 | | |
567 | 568 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5760 | 5760 | | |
5761 | 5761 | | |
5762 | 5762 | | |
| 5763 | + | |
| 5764 | + | |
| 5765 | + | |
| 5766 | + | |
| 5767 | + | |
| 5768 | + | |
| 5769 | + | |
| 5770 | + | |
| 5771 | + | |
| 5772 | + | |
| 5773 | + | |
| 5774 | + | |
| 5775 | + | |
| 5776 | + | |
| 5777 | + | |
| 5778 | + | |
| 5779 | + | |
| 5780 | + | |
| 5781 | + | |
| 5782 | + | |
| 5783 | + | |
| 5784 | + | |
| 5785 | + | |
| 5786 | + | |
| 5787 | + | |
| 5788 | + | |
| 5789 | + | |
| 5790 | + | |
| 5791 | + | |
| 5792 | + | |
| 5793 | + | |
| 5794 | + | |
| 5795 | + | |
| 5796 | + | |
| 5797 | + | |
| 5798 | + | |
| 5799 | + | |
| 5800 | + | |
| 5801 | + | |
5763 | 5802 | | |
5764 | 5803 | | |
5765 | 5804 | | |
| |||
0 commit comments