Responsive images and mobile overflow (AISD-206)¶
Chrome CSS and shell HTML live as versioned S3 files (styles registry +
template shells). Content ships prepared image variants in settings
(featured_image_sm / featured_image_opt), exposed on public v2 as
image_sm / image_opt. The worker prefers those assets instead of inventing
CDN width transforms.
Source:
src/pages/_shared.ts(pickImage,buildPreparedSrcset,responsiveImgAttrs,normalizeFixedWidths),src/pages/article.ts,templates/styles/*/,templates/templates/*/.
Image variant preference¶
| Slot | Size hint | Resolution order |
|---|---|---|
| Cards / grids / sidebar / related | "sm" |
image_sm → image_opt → image → featured_image |
| Hero / featured / large in-body | "opt" |
image_opt → image_sm → image → featured_image |
mapArticleItem(it, size) writes the picked URL into featured_image for
templates. List pages already pass "sm" for cards and "opt" for the homepage
hero.
For <img> tags the worker builds from content blocks, responsiveImgAttrs
emits src from pickImage and, when both a small and large prepared URL
exist, a srcset of image_sm 480w + image_opt|origin 1200w with
sizes="(max-width: 768px) 100vw, 1200px". Non-hero images also get
loading="lazy" / decoding="async".
Body HTML normalization¶
Imported article HTML often carries fixed widths (width="1200",
width="1200px", style="width:1200px"). normalizeFixedWidths strips
numeric width/height attributes (bare digits or with a px suffix,
quoted or unquoted) and px width / min-width style declarations before
blocks are injected into the page. Percentage widths are left alone.
Style CSS (S3) — all skins share the fluid baseline¶
Local mirrors under templates/styles/<slug>/<version>.css are the edit
surface; the active object in the cms-templates bucket is the source of
truth. Every registered skin carries the same mobile/overflow baseline:
img { max-width: 100%; height: auto; display: block }html, body { overflow-x: clip }.author-info { min-width: 0 }(was240px)@media (max-width: 480px)— tighter padding, single-column authors / contact / footer grids, smaller hero type (in addition to the existing720pxnav/hero/card breakpoint)
Current registry inventory (stg)¶
| Style slug | Role | Active object |
|---|---|---|
default |
Platform default skin | styles/default/<version>.css |
celebrity-v1 |
Celebrity skin | styles/celebrity-v1/<version>.css |
celebrity-sunset |
Celebrity warm variant | styles/celebrity-sunset/<version>.css |
editorial-magazine |
Editorial skin | styles/editorial-magazine/<version>.css |
Template↔style pairings (template_styles) only choose which of these
files a site links; they do not carry separate CSS. Changing a site's
template_style_id switches skins without a worker code change.
Publish a new CSS version¶
# Replace STYLE_ID / TOKEN / path for the environment
curl -X POST "https://cms-api-stg.skyneto.com/admin/v1/styles/${STYLE_ID}/file" \
-H "Authorization: Bearer ${TOKEN}" \
-F "file=@templates/styles/<slug>/<version>.css"
Then follow the full propagation recipe in caching.md:
POST /__cms/purgewith{"host":"<host>","site":true}and a normal browserUser-Agent(Cloudflare may return error 1010 for bare clients).- Redeploy the site worker (
site-devon push tostagetoday) so isolate memMap drops stale settings. - Zone
purge_everythingfor the host's Cloudflare zone so edge HTML is not stuck on the old<link>.
Verify with the plain URL (no ?query).
Keep git mirrors aligned with active S3 keys — see
cms-cf-worker/templates/README.md.
Offender audit (AISD-206)¶
| Offender | Layer | Fix |
|---|---|---|
Global img missing height: auto |
S3 style CSS | Added in all four skins |
| Horizontal scroll from wide imported body | Worker normalize | normalizeFixedWidths on content blocks (incl. width="Npx") |
.author-info { min-width: 240px } on narrow phones |
S3 style CSS | min-width: 0 |
minmax(200px|240px) grids on ≤480px |
S3 style CSS | @media (max-width: 480px) single-column |
Cards requesting full featured_image |
Worker | mapArticleItem(..., "sm") → image_sm |
| Checklist / image blocks without srcset | Worker | responsiveImgAttrs from prepared variants |