Insert Images within Figure Element from Media Uploader
<?php
/**
* @link https://css-tricks.com/snippets/wordpress/insert-images-within-figure-element-from-media-uploader/
*/
function html5_insert_image( $html, $id, $caption, $title, $align, $url, $size, $alt ) {
if ( current_theme_supports( 'html5' ) ) {
$html = "<figure id='post-$id media-$id' class='align-$align'>";
$html .= "<img src='$url' alt='$title' />";
if ( $caption ) {
$html .= "<figcaption>$caption</figcaption>";
}
$html .= "</figure>";
}
return $html;
}
add_filter( 'image_send_to_editor', 'html5_insert_image', 10, 8 );