Automatically wrap post image in div
It’s the image_send_to_editor filter: 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” id=”mydiv-‘.$id.'”>’.$html.'</div>’; } } For existing images/posts you can try the regex in the function below