]*)>/iu', static function (array $m): string { $attrs = $m[1]; if (preg_match('/\sdata-src=(["\'])([^"\']+)\1/i', $attrs, $data)) { $realSrc = $data[2]; if (preg_match('/\ssrc=(["\'])([^"\']*)\1/i', $attrs)) { $attrs = preg_replace('/\ssrc=(["\'])[^"\']*\1/i', ' src="'.$realSrc.'"', $attrs); } else { $attrs .= ' src="'.$realSrc.'"'; } } if (! preg_match('/\sreferrerpolicy=/i', $attrs)) { $attrs .= ' referrerpolicy="no-referrer"'; } return ''; }, $html ) ?? $html; $html = preg_replace('#\ssrc=(["\'])/(?!/)#', ' src=$1https://www.pedaily.cn/', $html) ?? $html; $html = preg_replace('#\ssrc=(["\'])//#', ' src=$1https://', $html) ?? $html; return trim($html); } }