Skip to content

Commit

Permalink
🎨 Fill in the alt text after converting network images to local #10583
Browse files Browse the repository at this point in the history
  • Loading branch information
88250 committed Mar 12, 2024
1 parent 9a42f69 commit f168e39
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions kernel/model/assets.go
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,9 @@ func NetImg2LocalAssets(rootID, originalURL string) (err error) {
name := filepath.Base(u)
name = util.FilterUploadFileName(name)
name = util.TruncateLenFileName(name)
linkText.Tokens = []byte(name)
if 1 > len(bytes.TrimSpace(linkText.Tokens)) {
linkText.Tokens = []byte(name)
}
name = "net-img-" + name
name = util.AssetName(name)
writePath := filepath.Join(assetsDirPath, name)
Expand Down Expand Up @@ -209,7 +211,9 @@ func NetImg2LocalAssets(rootID, originalURL string) (err error) {
name = strings.TrimSuffix(name, ext)
name = util.FilterUploadFileName(name)
name = util.TruncateLenFileName(name)
linkText.Tokens = []byte(name)
if 1 > len(bytes.TrimSpace(linkText.Tokens)) {
linkText.Tokens = []byte(name)
}
name = "net-img-" + name + "-" + ast.NewNodeID() + ext
writePath := filepath.Join(assetsDirPath, name)
if err = filelock.WriteFile(writePath, data); nil != err {
Expand Down

0 comments on commit f168e39

Please sign in to comment.