Support » Fixing WordPress » How to remove hard coded dimensions from post gallery images?

  • Resolved joaoramos

    (@joaoramos)


    How can I insert pictures into a post without any hard coded dimensions (e.g. <img src="" alt=""/ > instead of <img src="" alt="" width="" height="" />)? I’m using this snippet, but it doesn’t seem to work properly with images pulled via wp_get_attachment_image();:

    `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);
    `
    Any ideas?
Viewing 4 replies - 1 through 4 (of 4 total)
Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘How to remove hard coded dimensions from post gallery images?’ is closed to new replies.