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

@@ -67,7 +67,8 @@ class ProjectTaskContent extends AbstractModel
Base::makeDir(public_path($tmpPath));
$tmpPath .= md5($text) . "." . $matchs[1][$key];
if (file_put_contents(public_path($tmpPath), base64_decode($text))) {
$content = str_replace($matchs[0][$key], '<img src="{{RemoteURL}}' . $tmpPath . '"', $content);
$paramet = getimagesize(public_path($tmpPath));
$content = str_replace($matchs[0][$key], '<img src="{{RemoteURL}}' . $tmpPath . '" original-width="' . $paramet[0] . '" original-height="' . $paramet[1] . '"', $content);
}
}
$pattern = '/<img(.*?)src=("|\')https*:\/\/(.*?)\/(uploads\/task\/content\/(.*?))\2/is';