How to automatically wrap image in a div

We can automatically wrap the image (sent from media upload box) in a div by applying a filter to the “image_send_to_editor” function.

Uploaded images (images added through media upload box) can be easily wrapped in a div by applying a filter to the image_send_to_editor function, like this:

function wcr_wrap_image($html, $id, $caption, $title, $align, $url, $size, $alt) {
    return '
' . $html . '
'; } add_filter('image_send_to_editor', 'wcr_wrap_image', 10, 8);

The code above will generate this output:

Leave a Reply

Your email address will not be published. Required fields are marked *