Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How do I get the header image for a post? #42

Open
DaleEMoore opened this issue Jan 31, 2023 · 1 comment
Open

How do I get the header image for a post? #42

DaleEMoore opened this issue Jan 31, 2023 · 1 comment

Comments

@DaleEMoore
Copy link

DaleEMoore commented Jan 31, 2023

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
Copy link
Author

Is it a good assumption on my part to use:

log.Println("URL is an image:", post.URL)

as the post's image?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant