I've tried the below code to wrap a post image with a div and it works. The problem I'm having is if the image has a caption. It screws up the the code that is generated when a caption is set for the image.
How can I modify this code to only be applied for an image with no caption?
if(is_admin()){
add_filter('image_send_to_editor', 'wrap_my_div', 10, 8);
function wrap_my_div($html, $id, $caption, $title, $align, $url, $size, $alt){
return '<div class="mydiv-'.$size.'" id="mydiv-'.$id.'">'.$html.'</div>';
}
}