diff --git a/resources/assets/js/functions/web.js b/resources/assets/js/functions/web.js
index 1d5c18489..023b3373e 100755
--- a/resources/assets/js/functions/web.js
+++ b/resources/assets/js/functions/web.js
@@ -675,11 +675,25 @@ import {MarkdownPreview} from "../store/markdown";
* @returns {*}
*/
getMsgTextPreview(text, imgClassName = null) {
- if (!text) return '';
+ if (!text) {
+ return '';
+ }
+ //
text = text.replace(/]*?alt="(\S+)"[^>]*?>/g, "[$1]")
text = text.replace(/
]*?>/g, `[${$A.L('动画表情')}]`)
if (imgClassName) {
- text = text.replace(/
]*?src="(\S+)"[^>]*?>/g, `[image:$1]`)
+ text = text.replace(/
]*?src="(\S+)"[^>]*?>/g, function (res, src) {
+ const widthMatch = res.match("width=\"(\\d+)\""),
+ heightMatch = res.match("height=\"(\\d+)\"");
+ if (widthMatch && heightMatch) {
+ const width = parseInt(widthMatch[1]),
+ height = parseInt(heightMatch[1]),
+ maxSize = 40;
+ const scale = $A.scaleToScale(width, height, maxSize, maxSize);
+ imgClassName = `${imgClassName}" style="width:${scale.width}px;height:${scale.height}px`
+ }
+ return `[image:${src}]`
+ })
} else {
text = text.replace(/
]*?>/g, `[${$A.L('图片')}]`)
}
@@ -770,11 +784,11 @@ import {MarkdownPreview} from "../store/markdown";
if (widthMatch && heightMatch) {
const width = parseInt(widthMatch[1]),
height = parseInt(heightMatch[1]),
- maxSize = res.indexOf("emoticon") > -1 ? 150 : 220;
+ maxSize = res.indexOf("emoticon") > -1 ? 150 : 220; // 跟css中的设置一致
const scale = $A.scaleToScale(width, height, maxSize, maxSize);
const value = res
- .replace(widthReg, `original-width="${width}" width="${scale.width}"`)
- .replace(heightReg, `original-height="${height}" height="${scale.height}"`)
+ .replace(widthReg, `original-width="${width}"`)
+ .replace(heightReg, `original-height="${height}" style="width:${scale.width}px;height:${scale.height}px"`)
text = text.replace(res, value)
} else {
text = text.replace(res, `