🎨 Improve image export size for database assets fields https://github.com/siyuan-note/siyuan/issues/16470

Signed-off-by: Daniel <845765@qq.com>
This commit is contained in:
Daniel 2026-01-17 10:45:04 +08:00
parent 6ee0b663e2
commit 3e6e5fa3a4
No known key found for this signature in database
GPG key ID: 86211BA83DF03017
2 changed files with 26 additions and 4 deletions

View file

@ -2831,10 +2831,14 @@ func exportTree(tree *parse.Tree, wysiwyg, keepFold, avHiddenCol bool,
img.AppendChild(&ast.Node{Type: ast.NodeLinkDest, Tokens: []byte(a.Content)})
img.AppendChild(&ast.Node{Type: ast.NodeCloseParen})
mdTableCell.AppendChild(img)
height := "height: 128px;"
spanIAL := &ast.Node{Type: ast.NodeKramdownSpanIAL, Tokens: []byte("style=\"" + height + "\"")}
mdTableCell.AppendChild(spanIAL)
img.SetIALAttr("style", height)
img.SetIALAttr("style", "max-height: 128px;")
width, height := GetAssetImgSize(a.Content)
if height > 128 {
img.SetIALAttr("height", "128px")
newWidth := int(float64(width) * (128.0 / float64(height)))
img.SetIALAttr("width", strconv.Itoa(newWidth)+"px")
}
} else if av.AssetTypeFile == a.Type {
linkText := strings.TrimSpace(a.Name)
if "" == linkText {