Deleting a pod record with an image - image remains in the WP media library
Hello,
I've noticed that when I delete a Pod record containing an image that image stays in the WP media library (inc. all the sizing versions of that image). It is possible to ensure the deletion of an image and all its sizes when deleting a Pod record referring to it?
5 Answers
Got this working. Released as a Package here http://podscms.org/packages/clear-up-wp-media-library-files/
edited Oct 6 '10 at 1:01
Pre-drop helper & wp delete attachment function should make it. I don't know exactly how the data is stored in $columns (it may be array or string), but in any way you should get array with related media IDs, loop through it and use wp_ delete_ attachment with each of them.
You don't have access to $columns, you can use $params->tbl_row_id to pull in data via a new Pod() though to fit your needs.
Hm, just looked at the codex and there isn't much info on the pre-drop helpers. Do they have the same variables as pre-save helpers? Do I access field's value using $columns['column_name']['value'] ?
Any help?
I've been looking at it more. Still confused...
As I understand $params relates to 'wp_pod' table. When I get $params->datatype I would need to look into the 'wp_pod_types' table to retrieve the 'name' field of a Pod, so I'll have '<pods_name>'. Then I need to look into 'wp_pod_tbl_<pods_name>' and get the row/item with 'id = $params->tbl_row_id'. Then to get access to attachment I need to 'get_field('<attachment_col_name>.ID')' on the retrieved row/item.
The problem is that I don't know how to start it off and access 'wp_pod_types' and other 'wp_pod_<table_name>' required tables.
Do I need a custom SQL specifing all tables and relations myself? :S
edited Oct 6 '10 at 10:15


