Skip to content

Commit 302d5a8

Browse files
committed
♻️ 图片缩略
1 parent fa7fd9c commit 302d5a8

3 files changed

Lines changed: 6 additions & 6 deletions

File tree

‎controller/console/articlectl.go‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -296,8 +296,7 @@ func GetArticleThumbsAction(c *gin.Context) {
296296

297297
var styledURLs []string
298298
for _, url := range urls {
299-
styledURLs = append(styledURLs, url+"?imageView2/1/w/"+strconv.Itoa(w)+
300-
"/h/"+strconv.Itoa(h)+"/interlace/1/q/100")
299+
styledURLs = append(styledURLs, util.ImageSize(url, w, h))
301300
}
302301

303302
result.Data = styledURLs

‎model/themestruct.go‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@ package model
1818

1919
import (
2020
"html/template"
21-
"strconv"
21+
22+
"github.com/b3log/pipe/util"
2223
)
2324

2425
// ThemeArticle represents theme article.
@@ -62,7 +63,7 @@ type ThemeAuthor struct {
6263

6364
// AvatarURLWithSize returns avatar URL with the specified size.
6465
func (author *ThemeAuthor) AvatarURLWithSize(size int) string {
65-
return author.AvatarURL + "?imageView2/1/w/" + strconv.Itoa(size) + "/h/" + strconv.Itoa(size) + "/interlace/1/q/100"
66+
return util.ImageSize(author.AvatarURL, size, size)
6667
}
6768

6869
// ThemeCategory represents theme category.

‎model/user.go‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
package model
1818

1919
import (
20-
"strconv"
20+
"github.com/b3log/pipe/util"
2121
)
2222

2323
// User model.
@@ -43,5 +43,5 @@ const (
4343

4444
// AvatarURLWithSize returns avatar URL with the specified size.
4545
func (u *User) AvatarURLWithSize(size int) string {
46-
return u.AvatarURL + "?imageView2/1/w/" + strconv.Itoa(size) + "/h/" + strconv.Itoa(size) + "/interlace/1/q/100"
46+
return util.ImageSize(u.AvatarURL, size, size)
4747
}

0 commit comments

Comments
 (0)