Skip to content

Remediation Flow

How file remediation works, with a focus on images and alt text.

Overview

Remediation takes existing HTML (or content fetched from a URL) and fixes accessibility issues to meet WCAG 2.1 AA. The system supports three input modes:

  1. Single HTML file β€” POST /api/remediate/html
  2. Batch HTML files β€” POST /api/remediate/batch (up to 50 files, returns ZIP)
  3. URL scan β€” POST /api/remediate/url (fetches a URL, discovers linked files, audits and remediates)

Step-by-Step Flow

1. Pre-Audit (URL mode only)

For URL remediation, the system runs a WCAG audit on the fetched HTML before any changes. If the file already passes (zero violations), it is marked β€œNo Issues” and skipped. Only files that fail the audit proceed to remediation.

2. Image Alt Text Generation

The first remediation step scans the HTML for <img> tags that need alt text.

An image is flagged as needing alt text when:

  • The alt attribute is completely missing
  • The alt attribute is empty (alt="")
  • The alt text is a generic placeholder: "image", "picture", "img1", etc.

For each flagged image, the system:

  1. Checks if the image is a base64 data URL (inline). If so, extracts the base64 data directly.

  2. If the image is an external URL (http://...), fetches it and converts to base64.

  3. Sends the image data to a vision AI model with this prompt:

    Describe this image for a screen reader user. Be concise but informative. Include what the image shows, any visible text, and the purpose or context if apparent. Keep the description under 125 characters if possible. Do not start with β€œImage of” or β€œPicture of”.

  4. Replaces the original alt attribute (or adds one) with the AI-generated description.

Supported vision models (configurable per request):

ModelProviderDefault
gemini-flashGoogle Gemini 1.5 FlashYes
gpt-4o-miniOpenAINo
claude-haikuAnthropic Claude 3 HaikuNo
claude-sonnetAnthropic Claude SonnetNo

If the image cannot be fetched or the AI call fails, the image is skipped silently and the original alt (or lack thereof) is preserved.

3. Static Accessibility Fixes

After image remediation, the system applies structural fixes:

FixWhat it does
Language attributeAdds lang="en" to <html> if missing
Heading hierarchyFixes skipped heading levels (e.g., h1 β†’ h4 becomes h1 β†’ h2)
Main landmarkWraps body content in <main> if no <main> element exists
Table headersAdds scope="col" to <th> elements missing a scope
Link namesAdds aria-label to image-only links using the image’s alt text
Skip navigationAdds a skip-to-content link after <body> if missing

Each fix can be toggled on/off via the request options (fixHeadings, fixLandmarks, fixTables, fixLinks, fixForms).

4. Post-Audit

After all fixes are applied, the system runs the WCAG validator on the remediated HTML. The result includes:

  • Violations β€” issues that cause the audit to fail (e.g., missing alt attribute entirely)
  • Warnings β€” issues flagged for review but that don’t fail the audit (e.g., empty alt text, missing h1)

A file passes the audit when it has zero violations.

5. Output

The response includes:

  • The remediated HTML
  • Count of images remediated
  • List of fixes applied
  • WCAG audit result (pass/fail, violations, warnings)
  • Processing time

For URL mode, the output also includes a downloadable ZIP containing:

  • Remediated HTML files (root level)
  • Original HTML files (original/ directory)
  • Discovered CSS/JS assets
  • A standalone wcag-report.html with before/after audit details

Images and Alt Text: What Counts as a Violation vs. Warning

ConditionClassificationFails Audit?
<img> with no alt attribute at allViolation (critical)Yes
<img alt=""> (empty alt)WarningNo
<img alt="image"> or similar placeholderTreated as needing remediationN/A (gets replaced by AI)

Current Limitation

Images with alt="" are treated as warnings, not violations. Per WCAG, alt="" is valid for decorative images. The system currently cannot distinguish decorative images from content images, so it flags these as warnings for manual review rather than failing the audit.

During remediation, images with empty or placeholder alt text do get sent to the vision model for alt text generation. So even though alt="" doesn’t fail the audit, the remediator will still attempt to generate a description for it.

Architecture

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ Frontend │────▢│ /api/remediate/* │────▢│ html-remediator β”‚
β”‚ (Upload or β”‚ β”‚ (Hono route) β”‚ β”‚ β”‚
β”‚ URL scan) β”‚ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β”‚ 1. Extract imgs β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β”‚ 2. Vision AI β”‚
β”‚ 3. Static fixes β”‚
β”‚ 4. WCAG audit β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Key files:

  • workers/api/src/routes/remediate.ts β€” API endpoints
  • workers/api/src/services/html-remediator.ts β€” Core remediation logic + alt text generation
  • workers/api/src/services/wcag-validator.ts β€” Full WCAG 2.1 AA validator (26 rules)