[wp-trac] [WordPress Trac] #20720: attachment_fields_to_save filter is called twice after initial image upload in post
WordPress Trac
wp-trac at lists.automattic.com
Mon May 21 16:18:41 UTC 2012
#20720: attachment_fields_to_save filter is called twice after initial image upload
in post
--------------------------+-----------------------------
Reporter: williamsba1 | Owner:
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting Review
Component: Media | Version: 3.4
Severity: normal | Keywords:
--------------------------+-----------------------------
I believe I found a bug in WordPress with the attachment_fields_to_save
filter. For some reason attachment_fields_to_save is called twice per
image, but only if you "Save all changes" after uploading a new image to a
post.
How to reproduce:
1. Add the below code to a plugin:
{{{
add_filter( 'attachment_fields_to_save', 'test_attachment_fields_to_save',
10, 2 );
function test_attachment_fields_to_save( $post, $attachment ) {
echo 'Hi! </br >';
return $post;
}
}}}
2. Create a new post
3. Upload a single image and click "Save all changes"
You'll see "Hi!" displayed twice. Now visit the Gallery tab and save the
same image and you'll see "Hi!" is only displayed once. This only happens
when you save a new image uploaded to a post. If you save an image under
the Gallery tab, or via the Media Library, the filter is only called once
as expected.
I confirmed this is happening in 3.3.1 and trunk
--
Ticket URL: <http://core.trac.wordpress.org/ticket/20720>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software
More information about the wp-trac
mailing list