Lego2012
12/13/2016 - 10:59 AM

Insert Images with Figure/Figcaption

Insert Images with Figure/Figcaption

<!-- https://gist.github.com/3388415 -->

<!-- For a simple plugin or functions.php file: -->

function html5_insert_image($html, $id, $caption, $title, $align, $url) {
  $html5 = "<figure id='post-$id media-$id' class='align-$align'>";
  $html5 .= "<img src='$url' alt='$title' />";
  if ($caption) {
    $html5 .= "<figcaption>$caption</figcaption>";
  }
  $html5 .= "</figure>";
  return $html5;
}
add_filter( 'image_send_to_editor', 'html5_insert_image', 10, 9 );