How do I get the header image for a post?
Opened this issue · 1 comments
DaleEMoore commented
Howdy all y'all,
I'm trying to find and display a post's header image.
Is this a good place to look for it?
posts, resp, err = cl.Subreddit.TopPosts(ctx, subreddit, &reddit.ListPostOptions{
ListOptions: reddit.ListOptions{
Limit: maxRedditItems,
After: respAfter,
},
Time: "all",
})
var thePosts []*reddit.Post = nil
for _, post := range posts {
lastByByte := strings.ToLower(post.URL[len(post.URL)-4:])
if (lastByByte == ".jpg") || (lastByByte == ".png") {
log.Println("URL is an image:", post.URL)
} else {
log.Println("URL is NOT an image:", post.URL)
}
thePosts = append(thePosts, post)
}
Thanks for any help!
Dale
DaleEMoore commented
Is it a good assumption on my part to use:
log.Println("URL is an image:", post.URL)
as the post's image?