function custom_attr_to_img($html, $id, $caption, $title, $align, $url, $size, $alt) {
$html = sprintf('<a href="#" data-lazy="'. esc_attr(esc_url($url)).'"><img alt="%2$s" src="%1$s" /></a>', esc_attr(esc_url($url)), esc_attr($title));
return $html;
}
add_filter('image_send_to_editor', 'custom_attr_to_img', 10, 8);