Ask your WordPress questions! Pay money and get answers fast! Comodo Trusted Site Seal
Official PayPal Seal

WP 3.5 Update: Filter attachment_fields_to_edit Stopped Working WordPress

Following an upgrade to WP3.5 Elvin, a plugin that duplicates images (by duplicating metadata, not by actually copying the image) stopped working.

The plugin, [[LINK href="http://wordpress.org/extend/plugins/duplicate-images/"]]BDN Duplicate Images[[/LINK]], consists of just one file and can be [[LINK href="http://wordpress.org/extend/plugins/duplicate-images/"]]found here[[/LINK]].

The issue appears to be with the <strong>attachment_fields_to_edit</strong> filter. For some reason the attachment page won't return the "attach" link in <strong>media-upload.php?tab=library</strong> anymore.

Everything seems sound in the code to me. Does anyone know what is wrong?
Could someone propose a solution for this issue for me?

I suspect I'm missing something simple.

Answers (2)

2013-04-15

Arnav Joy answers:

try this full code of plugin

http://pastebin.com/JmhNvwAj

2013-04-15

Daniel Yoen answers:

please try this :

add_filter( 'attachment_fields_to_edit', 'bdn_add_link_to_attach_image_to_post', 20, 2 );
function bdn_add_link_to_attach_image_to_post($form_fields, $post) {

$post_id = get_post($post->ID)->post_parent;

$nonce = wp_create_nonce('bdn-attach_' . $post->ID );
$attach_image_action_url = admin_url( "media-upload.php?tab=library&post_id=" . $post_id . "&bdn-attach=" . $post->ID . "&_attachnonce=" . $nonce);

$form_fields['bdn_attach'] = array(
'value' => $attach_image_action_url ? $attach_image_action_url : '',
"input" => "text",
'label' => __('Attach to story:')
);
return $form_fields;
}


hope this help :-)