I am using the following code to wrap my images with figure when i send the images to the editor.

// Wrap the inserted image html with <figure>
    function html_insert_image( $html, $id, $caption, $title, $align, $url, $size, $alt ) {
      $src  = wp_get_attachment_image_src( $id, $size, false );
      $html = "<figure id="post-$id media-$id" class="align-$align">";
      if ( $url ) {
      $html .= "<a href="$url" class="image-link"><img src="$src[0]" title="$title" alt="$alt" /></a>";
  } else {
      $html .= "<img src="$src[0]" title="$title" alt="$alt" />";
  if ( $caption ) {
      $html .= "<p class='wp-caption-text'>$caption</p>";
      $html .= "</figure>";
      return $html;
add_filter( 'image_send_to_editor', 'html_insert_image', 10, 9 );

But the title tag returns empty like title=""any idea how to solve my problem?

Read more here: Function image_send_to_editor returns emty title tag


If you know the solution of this issue, please leave us a reply in Comment section, to update the question.

Wordpress related questions and answers: