- if ($isLocal && !file_exists($pathString)) continue;
- try {
- $imageContent = file_get_contents($pathString);
- $imageEncoded = 'data:image/' . pathinfo($pathString, PATHINFO_EXTENSION) . ';base64,' . base64_encode($imageContent);
- $newImageString = str_replace($srcString, $imageEncoded, $oldImgString);
- } catch (\ErrorException $e) {
- $newImageString = '';
- }
- $htmlContent = str_replace($oldImgString, $newImageString, $htmlContent);
+ $newImgTagString = str_replace($srcString, $imageEncoded, $oldImgTagString);
+ $htmlContent = str_replace($oldImgTagString, $newImgTagString, $htmlContent);