Accurately determining the type of a reddit post (text, image, video, link, gallery, mix of all the previous) is actually a lot harder than it might first seem. The core issue is that reddit has no standardized way of uploading media (compared to other platforms like twitter for example). This because reddit at its core is a link sharing site.
Some of the edge cases:
Someone posts a link to imgur.com/a/abcxyz (or any other media sharing site). Just given the url, you don't know if it's an image, video or gallery, without making an api request to imgur. Now days reddit often provides a reddit hosted version, but that is not always the case.
Sometimes links to external media sharing sites, are only embedded as iframes. Is a link to youtube video a link or a video post?
What if someone posts a gallery containing both images and videos? What about 10 images followed by a 1 second long video? Fun fact, more and more repost bots convert images to static gifs in order to bypass repost detectors.
Reddit allows embedding media into text posts. Now it is happening more and more often, that people make text posts only containing a single image. Is this now a text or image post?
Technically the "post_hint" field could be used. It has the following possible values: "link"|"image"|"self"|"video"|"hosted:video"|"rich:video"|"gallery". But due to the above concerns, I wouldn't rely on it that much.
TLDR; it's complicated and you will have to do the filtering on your end, so that it fits your needs.
Accurately determining the type of a reddit post (text, image, video, link, gallery, mix of all the previous) is actually a lot harder than it might first seem. The core issue is that reddit has no standardized way of uploading media (compared to other platforms like twitter for example). This because reddit at its core is a link sharing site.
Some of the edge cases:
Technically the
"post_hint"
field could be used. It has the following possible values:"link"|"image"|"self"|"video"|"hosted:video"|"rich:video"|"gallery"
. But due to the above concerns, I wouldn't rely on it that much.TLDR; it's complicated and you will have to do the filtering on your end, so that it fits your needs.