public static function removeRemoteImages(string $html) : string
{
static $remoteImages = ['~(<img[^>]+src=")http(?:s)?://[^"]+(")~i', '~(<[a-z][a-z0-9]*[^>]+background=")http(?:s)?://[^"]+(")~i', '~(<[a-z][a-z0-9]*[^>]+style="[^"]*background\\s*[:])([\\-a-z0-9#%\\s]*)url\\([^)]+\\)(;)?~is', '~(<[a-z][a-z0-9]*[^>]+style="[^"]*)background-image\\s*[:]([\\-a-z0-9#%\\s]*)url\\([^)]+\\)(;)?~is', '~(<[a-z][a-z0-9]*[^>]+style="[^"]*list-style\\s*[:])([\\-a-z0-9\\s]*)url\\([^)]+\\)(;)?~is', '~(<[a-z][a-z0-9]*[^>]+style="[^"]*)list-style-image\\s*[:]([\\-a-z0-9\\s]*)url\\([^)]+\\)(;)?~is'];
// We use value about:blank for the <img> tag's src attribute, because removing the tag entirely could affect the page layout
static $remoteImagesReplacement = ['\\1about:blank\\2', '\\1\\2', '\\1\\2\\3', '\\1', '\\1\\2\\3', '\\1'];
return preg_replace($remoteImages, $remoteImagesReplacement, $html);
}