Multiple images in HTML
This commit is contained in:
parent
95fc73543c
commit
40faf3da48
1 changed files with 8 additions and 0 deletions
|
|
@ -244,6 +244,7 @@ func (timeline *timeline) parseTweet(id string) *Tweet {
|
||||||
username,
|
username,
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
var foundedMedia []string
|
||||||
tw.HTML = reTwitterURL.ReplaceAllStringFunc(tw.HTML, func(tco string) string {
|
tw.HTML = reTwitterURL.ReplaceAllStringFunc(tw.HTML, func(tco string) string {
|
||||||
for _, entity := range tweet.Entities.URLs {
|
for _, entity := range tweet.Entities.URLs {
|
||||||
if tco == entity.URL {
|
if tco == entity.URL {
|
||||||
|
|
@ -252,11 +253,18 @@ func (timeline *timeline) parseTweet(id string) *Tweet {
|
||||||
}
|
}
|
||||||
for _, entity := range tweet.ExtendedEntities.Media {
|
for _, entity := range tweet.ExtendedEntities.Media {
|
||||||
if tco == entity.URL {
|
if tco == entity.URL {
|
||||||
|
foundedMedia = append(foundedMedia, entity.MediaURLHttps)
|
||||||
return fmt.Sprintf(`<br><a href="%s"><img src="%s"/></a>`, tco, entity.MediaURLHttps)
|
return fmt.Sprintf(`<br><a href="%s"><img src="%s"/></a>`, tco, entity.MediaURLHttps)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return tco
|
return tco
|
||||||
})
|
})
|
||||||
|
for _, url := range tw.Photos {
|
||||||
|
if stringInSlice(url, foundedMedia) {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
tw.HTML += fmt.Sprintf(`<br><img src="%s"/>`, url)
|
||||||
|
}
|
||||||
tw.HTML = strings.Replace(tw.HTML, "\n", "<br>", -1)
|
tw.HTML = strings.Replace(tw.HTML, "\n", "<br>", -1)
|
||||||
return tw
|
return tw
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue