You can wrap specific sizes in arbitrary html when they’re inserted into post content via the image_send_to_editor
filter.
Here we check if $size
is thumbnail
and wrap it in a div, otherwise we just return the unaltered $html
:
function wpd_wrap_thumbnails( $html, $id, $caption, $title, $align, $url, $size, $alt ){
if( 'thumbnail' == $size ){
return '<div class="circle">' . $html . '</div>';
}
return $html;
}
add_filter( 'image_send_to_editor', 'wpd_wrap_thumbnails', 10, 8 );
You can also add an editor stylesheet with your CSS, so the client sees them styled properly within the editor.