Embed
Two lines of HTML put a gallery of C64 artwork on any page. Point it at an artist, a party compo, a category or a list of artworks you picked yourself. Every colour, size and caption is an option, and the widget can hand a chosen artwork back to your own JavaScript. It needs no account, no key and no server of your own.
Quick start
Paste this where the gallery should appear. The script tag goes in once per page, wherever you like.
<div data-c64gfx-embed data-source="artist:848" data-limit="8"></div>
<script src="https://c64gfx.com/embed.js" async></script>
That is a Raistlin gallery: everything of theirs on C64GFX, most-liked first.
Build your embed
Set it up here and copy the snippet at the bottom. The preview is the real widget.
Preview
Your snippet
Examples
Each one below is live on this page, and the snippet under it is generated from the markup it is running on — so what you copy is exactly what you are looking at.
One artist, newest first
An artist id is the number in their page address, e.g.
c64gfx.com/artist/848-raistlin.html.
A party's graphics compo
For a party website: the artwork entered into that event's compos. Revision 2026 is
event 3608 — the number in c64gfx.com/compo/3608.html.
A category, in one scrolling row
Light theme, square crops, no captions — a strip that sits in a sidebar.
Artworks you picked yourself
List the ids and they are shown in that order — for a page about six specific pictures rather than a whole gallery.
A picker that hands the choice back to your page
With data-select set, a click selects instead of navigating and your own
code hears about it. Pick one below.
Nothing picked yet.
Every option
Written as data- attributes on the <div>. The same names in
camelCase work when you create an embed from JavaScript
(data-min-column-width is minColumnWidth).
What to show
| Attribute | Default | What it does |
|---|---|---|
data-source | collection:newest |
Where the artwork comes from: artist:<id>,
event:<id>,
tag:<name>, collection:newest,
collection:popular, or images:<id>,<id>.
An id copied out of a page address keeps its name (artist:848-raistlin). |
data-limit | 12 |
Most artworks the embed will ever show. |
data-page-size | the limit | How many are drawn before the "Show more" button. |
data-sort | — | newest, oldest, likes,
title, random or id. Left off, the order
is the site's own ranking for that source. |
data-tags | — | Keep only artwork in these categories, comma separated
(petscii, logo). |
data-tags-match | any |
all requires every listed category rather than any of them. |
data-years | — | 1991, 1990-1995, 2000- or a list of
those. |
data-search | — | Keep only artwork whose title, artist or category contains this text. |
data-ids | — | Keep only these artwork ids, within whatever source is set. |
data-exclude-ids | — | Drop these artwork ids. |
data-min-likes | 0 |
Keep only artwork with at least this many likes on C64GFX. |
data-adult | hide |
What to do with artwork flagged 18+: hide, blur
or show. |
Layout
| Attribute | Default | What it does |
|---|---|---|
data-layout | grid |
grid, row (one scrolling row), list
or single. |
data-columns | 0 |
At most this many columns — fewer when the space is too narrow for them, so a phone still gets whole pictures rather than a squeezed row. 0 fits as many as the width allows. |
data-min-column-width | 170 |
Narrowest a column may get, in pixels, before the grid drops one. |
data-gap | 12 | Space between cards, in pixels. |
data-aspect | — | Force a picture shape, e.g. 4:3 or 1:1. Left off,
each picture keeps its own. |
data-fit | cover |
With an aspect set: cover crops, contain letterboxes. |
data-caption | below |
below, overlay or none. |
data-show-title | true | Artwork title in the caption. |
data-show-artist | true | Artist names in the caption. |
data-show-year | false | Release year in the caption. |
data-show-tags | false | Category pills in the caption. |
data-show-likes | false | Like count in the caption. |
data-heading | — | A heading above the gallery. |
data-show-count | false |
Show how many artworks the source holds beside the heading. |
data-more | true | Offer a "Show more" button. |
data-more-text | Show more | That button's label. |
data-empty-text | No artwork matched. |
What to say when the filters leave nothing. |
Colours and type
Colours take anything CSS does — #ffcc00, rgb(…),
transparent, or a custom property of your own site.
| Attribute | Default | What it does |
|---|---|---|
data-theme | dark |
dark or light. Sets every colour below; any one of
them can then be overridden. |
data-bg | transparent | Behind the whole embed. |
data-card-bg | theme | Behind each card. |
data-border | theme | Card border colour. |
data-border-width | 1 | Card border width, in pixels. |
data-text | theme | Caption text. |
data-muted | theme | Secondary caption text (artist, year, tags). |
data-accent | #ffcc00 |
Selection ring, focus ring, the tick on a selected card, link hover. |
data-accent-text | theme | Text drawn on the accent colour. |
data-radius | 6 | Corner radius, in pixels. |
data-padding | 0 | Space inside the embed's own edge. |
data-shadow | theme | Any CSS box-shadow value, or none. |
data-font | inherit | Any CSS font-family. Inherits your page's by default. |
data-font-size | 13 | Caption text size, in pixels. |
data-hover | lift |
lift, zoom, glow or none. |
data-pixelated | true |
Scale artwork with hard pixel edges rather than smoothing it. |
data-interlace | true |
Flip between both fields of an interlaced picture, as C64GFX does. Off shows one field. |
data-flip-ms | 34 | How long each interlace field is held. |
data-credit | true |
The link back to C64GFX under the gallery. Please leave it on if you can. |
data-credit-text | Artwork from C64GFX.com | Its wording. |
data-css | — | Extra CSS, applied inside the embed only. Easier from JavaScript than as an
attribute; ::part() from your own stylesheet works too. |
Clicking and selecting
| Attribute | Default | What it does |
|---|---|---|
data-link | image |
Where a card links: image, artist or
none. |
data-target | _blank | Link target. |
data-lightbox | false |
Open the picture larger in place instead of following the link. |
data-select | none |
single or multi turn the gallery into a picker:
clicking selects rather than navigating. |
data-selected | — | Artwork ids selected to begin with. |
data-onselect | — | The name of a function on your page to call with each selection, e.g.
data-onselect="myPicker.chose". |
data-site | where the script came from | Which C64GFX to read. You will not normally set this. |
Using it from JavaScript
Every embed on the page fires c64gfx:select on its own
<div> when a visitor picks an artwork. The event bubbles, so one listener
on the document catches every embed.
<div id="picker" data-c64gfx-embed data-source="artist:848" data-select="single"></div>
<script src="https://c64gfx.com/embed.js" async></script>
<script>
document.getElementById('picker').addEventListener('c64gfx:select', function (event) {
var picked = event.detail.image; // id, title, thumb, artists, year, tags, likes
console.log(picked.id, picked.title, picked.thumb);
});
</script>
You can also create one yourself, which is the only way to pass a function rather than the name of one:
var gallery = C64GFXEmbed.render('#picker', {
source: 'artist:848',
select: 'multi',
limit: 24,
accent: '#ff6699',
onSelect: function (detail) { console.log(detail.selectedIds); }
});
gallery.getSelection(); // the selected records
gallery.getSelectedIds(); // just the ids
gallery.setSelection([1234]); // select from your own code
gallery.update({ sort: 'random' }); // change options and redraw
gallery.refresh(); // re-read and redraw
gallery.destroy(); // remove it
C64GFXEmbed.scan() picks up any embed markup added to the page after load —
call it after inserting one yourself. C64GFXEmbed.get(el) returns the embed
already running on an element.
Styling from your own stylesheet
The widget renders in a shadow root, so your page's CSS cannot reach in by accident — and
your stylesheet cannot be broken by it either. When the options are not enough,
::part() reaches the pieces that matter:
#picker::part(card) { border-style: dashed; }
#picker::part(meta) { text-align: center; }
#picker::part(credit){ font-style: italic; }
Parts: root, head, heading,
grid, card, thumb, meta,
foot, more, credit, lightbox.
Worth knowing
- The data is plain static JSON under
c64gfx.com/api/embed/and the pictures come from our CDN. Nothing is written, no cookie is set, and no visitor of yours is identified to us. - It is rebuilt when the site is, so a new artwork or a changed like count shows up in your embed after the next C64GFX update rather than immediately.
- A very large source (a busy category, one of the most prolific artists) ships its most-liked 1000 artworks rather than all of them.
- 18+ artwork is left out unless you ask for it.
- Artwork stays the property of the artists who made it. An embed is a link back to their work, which is why the credit is on by default.
- Something not working, or an option missing? Leave a comment at the bottom of this page.