perf: 预览图片尺寸的优化

This commit is contained in:
kuaifan
2022-06-07 19:25:28 +08:00
parent 4c068f4a62
commit 33db978e36
7 changed files with 94 additions and 17 deletions

View File

@@ -525,7 +525,8 @@ class FileController extends AbstractController
Base::makeDir(public_path($tmpPath));
$tmpPath .= md5($text) . "." . $matchs[1][$key];
if (file_put_contents(public_path($tmpPath), base64_decode($text))) {
$data['content'] = str_replace($matchs[0][$key], '<img src="' . Base::fillUrl($tmpPath) . '"', $data['content']);
$paramet = getimagesize(public_path($tmpPath));
$data['content'] = str_replace($matchs[0][$key], '<img src="' . Base::fillUrl($tmpPath) . '" original-width="' . $paramet[0] . '" original-height="' . $paramet[1] . '"', $data['content']);
$isRep = true;
}
}