Opened 11 years ago
Closed 10 years ago
#23399 closed enhancement (duplicate)
Add filter wp_insert_attachment_data mirroring wp_insert_post_data
Reported by: |
|
Owned by: | |
---|---|---|---|
Milestone: | Priority: | normal | |
Severity: | minor | Version: | 3.5 |
Component: | Posts, Post Types | Keywords: | has-patch |
Focuses: | Cc: |
Description
In commercial applications it's handy to use the wp_insert_post_data filter in wp_insert_post() to control attributes of a post being inserted based on the user's role and other variables. We're using this to force content to go through a complex approval process which runs off of the post status.
wp_insert_attachment() does not have a similar filter, which makes content approval processes difficult to implement.
This patch adds a filter named wp_insert_attachment_data filter to wp_insert_attachment() which mirrors the form and functionality in wp_insert_post().
Attachments (1)
Change History (5)
#3
@
10 years ago
Bumping this.
I ran into a situation where this filter would have saved me an extra query: I would have been able to transform the data before it ever went into the database. But since there's no filter on this, there's no way to modify the attachment data going in via media_handle_slideload() before it hits the database, which means there's no opportunity for validation or data transformation.
Instead, the insert had to be performed before the validation / transformation step could be applied, which wasted a query.
Patch to post.php with wp_insert_attachment_data filter similar to wp_insert_post_data filter.