2
0
Fork 0
mirror of https://github.com/discourse/discourse.git synced 2026-03-04 01:15:08 +08:00
discourse/spec/fixtures/onebox/reddit_image.response
Rafael dos Santos Silva bab1033758
FIX: Switch Reddit onebox from OG scraping to JSON API (#38035)
Reddit removed OpenGraph meta tags from their HTML responses, so
oneboxing fails silently. This switches to fetching from Reddit's
`.json` API endpoint instead.

- Fetches post data from `.json` endpoint (appended to post URL)
- Supports image, video, and self/text posts
- Adds `matches_path` to restrict to actual post URLs
- Adds `old.reddit.com`, `np.reddit.com`, `new.reddit.com` support
- Flex-based layout for video post thumbnails (avoids legacy float
issues)


<img width="949" height="1434" alt="image"
src="https://github.com/user-attachments/assets/40b3f4fa-ace5-4dd1-97a9-45d9497037e4"
/>
2026-02-24 15:29:00 -03:00

43 lines
1.1 KiB
Text

[
{
"kind": "Listing",
"data": {
"children": [
{
"kind": "t3",
"data": {
"title": "Literally nothing black edition",
"author": "colorlover99",
"subreddit_name_prefixed": "r/colors",
"score": 4,
"num_comments": 1,
"selftext": "",
"is_self": false,
"post_hint": "image",
"is_video": false,
"over_18": false,
"url": "https://i.redd.it/vsg59iw0srn21.jpg",
"permalink": "/r/colors/comments/b4d5xm/literally_nothing_black_edition/",
"preview": {
"images": [
{
"source": {
"url": "https://preview.redd.it/vsg59iw0srn21.jpg?auto=webp&amp;s=e19452b85c0aa8e3563cb1006a36eb914abfdec7",
"width": 3024,
"height": 4032
}
}
]
}
}
}
]
}
},
{
"kind": "Listing",
"data": {
"children": []
}
}
]