Responsive images: Bootstrap 3 + WordPress Editor

Taken from: https://gist.github.com/mkdizajn/7352469

function bootstrap_responsive_images( $html ){
  $classes = 'img-responsive';
  // check if there are already classes assigned to the anchor
  if ( preg_match('/<img.*? class="/', $html) ) {
    $html = preg_replace('/(<img.*? class=".*?)(".*?\/>)/', '$1 ' . $classes . ' $2', $html);
  } else {
    $html = preg_replace('/(<img.*?)(\/>)/', '$1 class="' . $classes . '" $2', $html);
  }
  // remove dimensions from images,, does not need it!
  $html = preg_replace( '/(width|height)=\"\d*\"\s/', "", $html );
  return $html;
}
add_filter( 'the_content', __NAMESPACE__ . '\\bootstrap_responsive_images',10 );
add_filter( 'post_thumbnail_html', __NAMESPACE__ . '\\bootstrap_responsive_images', 10 );