Page Options: Student
Introduction
This Badge share plugin optimises the badge page link preview. Hence, when you are sharing your badges as links, they preview and display well everywhere.
It includes Open Graph and Twitter Card meta tags for Moodle badge pages — so when someone shares an awarded badge on LinkedIn, Slack, Teams, Bluesky, WhatsApp, or any other platform, the preview now shows the badge name, recipient, issuer, date, and the badge image, all public information on the page already.
This compares against the current display of “Issued badge information | Sitename” with the site logo, because the badge page emits no badge-specific Open Graph metadata.
Usage
On your badge share page, you may see a “Share this badge” panel rendered, if enabled, with one-click sharing buttons for LinkedIn, Bluesky, X/Twitter, Facebook, WhatsApp, email, and “copy link to clipboard.”
Each button opens the platform’s compose UI with the badge URL prefilled, and the rich preview is then drawn from the same Open Graph metadata.
The problem this solves
The problem is that by default, Moodle’s public badge page (/badges/badge.php?hash=…) emits no badge-specific Open Graph metadata. The badge artwork itself is rendered as a base64 data URI inside <img src=”data:image/png;base64,…”>, so social-sharing crawlers can’t fetch it as an image. Pasting a badge link into LinkedIn, Slack, or Bluesky produces a generic, useless preview — even on the latest Moodle, even on moodle.org itself.
This plugin fixes that.
- Open Graph tags on every public badge page (og:title, og:description, og:image, og:url, og:site_name, og:locale, og:type).
- Twitter Card tags (summary_large_image for padded mode, summary for raw).
- A public image endpoint that serves the badge artwork at a fetchable URL.
- An optional padded preview generator that produces a 1200×630 branded banner with the badge artwork centred on a brand-colour background. No text is baked into the image — all human-readable content lives in the meta tags where platforms render it as accessible HTML.
- A title format that carries the credential story: “Badge Name — awarded to Recipient on Date by Issuer”. On compact preview cards (LinkedIn) where only the title is visible, this means the recipient and issuer are still readable.
- A “Share this badge” panel rendered on the public badge page with one-click sharing buttons for LinkedIn, Bluesky, X/Twitter, Facebook, WhatsApp, email, and “copy link to clipboard.” Each button opens the platform’s compose UI with the badge URL prefilled, and the rich preview is then drawn from the same Open Graph metadata.
- Disk cache for padded images, automatically invalidated when a badge is updated, revoked, or deleted.
Why no baked-in text?
Earlier badge previews experimented with rendering badge details directly into the preview image.
We removed it because text-of-images:
- Fails WCAG 1.4.5 (Images of Text)
- Can’t be read by screen readers
- Doesn’t scale with the user’s text-size preferences
- Can’t be selected, copied, translated, or indexed
- All human-readable content now lives in og:title and og:description where platforms render it as accessible HTML. The image is just the image.