Skip to content

Instantly share code, notes, and snippets.

@tux255
Created November 24, 2016 13:39
Show Gist options
  • Save tux255/a56286e141bbe4d86c28912316c436e9 to your computer and use it in GitHub Desktop.
Save tux255/a56286e141bbe4d86c28912316c436e9 to your computer and use it in GitHub Desktop.
Wordpress snippet to filter Editor image adding
<?php
function html5_insert_image($html, $id, $caption, $title, $align, $url) {
$html5 = "<figure id='post-$id media-$id' class='align-$align'>";
$html5 .= "<img src='' data-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 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment