How to insert pictures without hard coded dimensions?

I don’t know if this is the best way to do this, but it works for me.

In the functions.php of the theme you are using, put this:

function remove_img_src($html)
{
    $html = preg_replace('@(width|height)="([0-9])+" ?@i', '', $html);

    return $html;
}

add_filter('image_send_to_editor', 'remove_img_src', 10, 8);

It uses regular expresions to change the output that is inserted in the editor.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)