Show the right cover
Every game that has a cover comes with it in three sizes, its dimensions and what the picture shows. Every file is stored and served by us: the API never sends another site’s address for an image.
The three sizes
Section titled “The three sizes”Each game object (in lists and on its own) carries:
| Field | What it is |
|---|---|
image |
The main cover, the original edition’s box front. |
medium |
The same, 500 pixels wide: cards and small screens. |
thumbnail |
The same, 250 pixels wide: lists and search results. |
imageWidth, imageHeight |
The size of image in pixels, to keep its place before it loads. |
All three are paths on the API (they start with /v1/media/): put
https://api.thebgdb.org in front. medium and thumbnail are the same
path as image when the cover is no wider than that size, and for
members’ photos. A game with no cover we hold has null in all three.
<img src="https://api.thebgdb.org/v1/media/covers/…-w500.jpg" srcset=" https://api.thebgdb.org/v1/media/covers/…-w250.jpg 250w, https://api.thebgdb.org/v1/media/covers/…-w500.jpg 500w, https://api.thebgdb.org/v1/media/covers/….jpg 1200w " sizes="(max-width: 600px) 45vw, 250px" width="1200" height="1200" alt="Wingspan"/>Set width and height from imageWidth and imageHeight (they can be
null: then reserve a square), so the page does not jump when the image
arrives. Covers are not all square: show them whole (object-fit: contain), never cropped.
Is it a good cover?
Section titled “Is it a good cover?”imageKindsays what the picture shows:box_frontis the whole front of the box; the reference lists the others.imageAcceptableistruefor a good cover: the whole front of the box, no person in it, a sharp enough picture, at least 300 pixels on its short side.falsemeans a better one is wanted; you may prefer your own placeholder then.imageLanguageis the language of the edition on the box, when a source states it. It is usuallynull.
To list only games with a good cover, filter the list:
curl "https://api.thebgdb.org/v1/games?cover=ok&order=ranked&limit=24"The box in the reader’s language
Section titled “The box in the reader’s language”GET /games/{id} also returns covers: the main cover first (primary: true), then the box of each other edition or name the game is sold under,
and members’ photos of a box that say which edition they show. Each carries
its language, its edition and the name printed on it:
function coverFor(game, lang: string) { const local = game.covers.find( (c) => c.language === lang && c.kind === "box_front", ); return local ?? game.covers.find((c) => c.primary) ?? null;}def cover_for(game, lang): local = next((c for c in game["covers"] if c["language"] == lang and c["kind"] == "box_front"), None) return local or next((c for c in game["covers"] if c["primary"]), None)Credits
Section titled “Credits”Some covers come from Wikimedia Commons, and some descriptions from
Wikipedia, under licences that ask for credit. GET /credits lists exactly
those, with the source, the licence and the author:
curl "https://api.thebgdb.org/v1/credits?kind=image&limit=50"Show the credit wherever you show such an image. Nothing else needs a credit line. Using the images and data is subject to the terms.