Automatically Insert alt attribute above image has h2

I find the solution using this How to change the markup WordPress inserts for post images

My final code is:

add_filter( 'image_send_to_editor', 'add_custom_data_attribute_send_to_editor', 10, 8 );
function add_custom_data_attribute_send_to_editor( $html, $id, $caption, $title, $align, $url, $size, $alt ){  
    if( $id > 0 ){
        $post = get_post( $id );
              $html = str_replace( "<img src", "<h2>$alt</h2><img src", $html );
    }
    return $html;
}