I want to add an option to the featured image metabox.
I have found a way to do this here
The problem I'm having is saving the value tot the database.
Here is what I have tried:
add_filter( 'admin_post_thumbnail_html', 'featured_image_opacity');
function featured_image_opacity( $myhtml ) {
//$selected_option = GET META OPACITY HERE
return $myhtml .= 'Opacity:
<form>
<select>
<option'. ($selected_option == "0.1" ? "selected" : "" ).' value="0.1">0.1</option>
</select>
</form>';
}
function meta_save( $post_id ) {
if( isset( $_POST[ 'opacity' ] ) ) {update_post_meta( $post_id, 'opacity', sanitize_text_field( $_POST[ 'opacity' ] ) );}
}
add_action( 'save_post', 'meta_save' );
I see the option-form and can select an option but it won't save the data.
(I have also tried to put the function within the function but that also doesn't work)
Hope somebody sees what I'm doing wrong.