Heya,
I am trying to add things within the media system (I.E., add custom classes to images/...).
While I found out how to display the field and all, it does not save if the media is not in a post / accessed through the media library, since the method I use requires the post id.
I found no explanation of how to get the Media's id within the media library's page.
function the_custom_classes_save( $post, $attachment ) {
if( isset( $attachment['the-custom-classes'] ) )
update_post_meta( $post['ID'], 'the_custom_classes', $attachment['the-custom-classes'] );
return $post;
}
add_filter( 'attachment_fields_to_save', 'the_custom_classes_save');
Is there a way to change that code to use the media's id and so on?
Thank you for your help!