Skip to content

Add image loading hints#1391

Open
mvvmm wants to merge 3 commits into
emdash-cms:mainfrom
mvvmm:media/image-loading-hints
Open

Add image loading hints#1391
mvvmm wants to merge 3 commits into
emdash-cms:mainfrom
mvvmm:media/image-loading-hints

Conversation

@mvvmm

@mvvmm mvvmm commented Jun 8, 2026

Copy link
Copy Markdown

What does this PR do?

Adds image loading hints to EmDash image components so consuming sites can prioritize above-the-fold images and opt into early promotion of deferred lazy images after initial page load.

Closes #

Type of change

  • Bug fix
  • Feature (requires maintainer-approved Discussion)
  • Refactor (no behavior change)
  • Translation
  • Documentation
  • Performance improvement
  • Tests
  • Chore (dependencies, CI, tooling)

Checklist

  • I have read CONTRIBUTING.md
  • pnpm typecheck passes
  • pnpm lint passes
  • pnpm test passes (or targeted tests for my change)
  • pnpm format has been run
  • I have added/updated tests for my changes (if applicable)
  • User-visible strings in the admin UI are wrapped for translation (if applicable). Do not include messages.po changes except in translation PRs — a workflow extracts catalogs on merge to main.
  • I have added a changeset (if this PR changes a published package)
  • New features link to an approved Discussion: https://github.com/emdash-cms/emdash/discussions/...

AI-generated code disclosure

  • This PR includes AI-generated code — model/tool: OpenCode + GPT-5.5

Screenshots / test output

  • pnpm format:check
  • pnpm --filter emdash typecheck

@changeset-bot

changeset-bot Bot commented Jun 8, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: f06430c

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 14 packages
Name Type
emdash Patch
@emdash-cms/cloudflare Patch
@emdash-cms/sandbox-workerd Patch
@emdash-cms/fixture-perf-site Patch
@emdash-cms/perf-demo-site Patch
@emdash-cms/cache-demo-site Patch
@emdash-cms/admin Patch
@emdash-cms/auth Patch
@emdash-cms/blocks Patch
@emdash-cms/gutenberg-to-portable-text Patch
@emdash-cms/x402 Patch
create-emdash Patch
@emdash-cms/auth-atproto Patch
@emdash-cms/plugin-embeds Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@github-actions

github-actions Bot commented Jun 8, 2026

Copy link
Copy Markdown
Contributor

All contributors have signed the CLA ✍️ ✅
Posted by the CLA Assistant Lite bot.

@github-actions github-actions Bot added area/core size/XS review/needs-review No maintainer or bot review yet labels Jun 8, 2026
@pkg-pr-new

pkg-pr-new Bot commented Jun 8, 2026

Copy link
Copy Markdown

Open in StackBlitz

@emdash-cms/admin

npm i https://pkg.pr.new/@emdash-cms/admin@1391

@emdash-cms/auth

npm i https://pkg.pr.new/@emdash-cms/auth@1391

@emdash-cms/auth-atproto

npm i https://pkg.pr.new/@emdash-cms/auth-atproto@1391

@emdash-cms/blocks

npm i https://pkg.pr.new/@emdash-cms/blocks@1391

@emdash-cms/cloudflare

npm i https://pkg.pr.new/@emdash-cms/cloudflare@1391

@emdash-cms/contentful-to-portable-text

npm i https://pkg.pr.new/@emdash-cms/contentful-to-portable-text@1391

emdash

npm i https://pkg.pr.new/emdash@1391

create-emdash

npm i https://pkg.pr.new/create-emdash@1391

@emdash-cms/gutenberg-to-portable-text

npm i https://pkg.pr.new/@emdash-cms/gutenberg-to-portable-text@1391

@emdash-cms/plugin-cli

npm i https://pkg.pr.new/@emdash-cms/plugin-cli@1391

@emdash-cms/plugin-types

npm i https://pkg.pr.new/@emdash-cms/plugin-types@1391

@emdash-cms/registry-client

npm i https://pkg.pr.new/@emdash-cms/registry-client@1391

@emdash-cms/registry-lexicons

npm i https://pkg.pr.new/@emdash-cms/registry-lexicons@1391

@emdash-cms/sandbox-workerd

npm i https://pkg.pr.new/@emdash-cms/sandbox-workerd@1391

@emdash-cms/x402

npm i https://pkg.pr.new/@emdash-cms/x402@1391

@emdash-cms/plugin-ai-moderation

npm i https://pkg.pr.new/@emdash-cms/plugin-ai-moderation@1391

@emdash-cms/plugin-atproto

npm i https://pkg.pr.new/@emdash-cms/plugin-atproto@1391

@emdash-cms/plugin-audit-log

npm i https://pkg.pr.new/@emdash-cms/plugin-audit-log@1391

@emdash-cms/plugin-color

npm i https://pkg.pr.new/@emdash-cms/plugin-color@1391

@emdash-cms/plugin-embeds

npm i https://pkg.pr.new/@emdash-cms/plugin-embeds@1391

@emdash-cms/plugin-field-kit

npm i https://pkg.pr.new/@emdash-cms/plugin-field-kit@1391

@emdash-cms/plugin-forms

npm i https://pkg.pr.new/@emdash-cms/plugin-forms@1391

@emdash-cms/plugin-webhook-notifier

npm i https://pkg.pr.new/@emdash-cms/plugin-webhook-notifier@1391

commit: f06430c

@mvvmm mvvmm changed the title Add image loading hints WIP: Add image loading hints Jun 8, 2026
@mvvmm mvvmm marked this pull request as draft June 8, 2026 23:25
@github-actions github-actions Bot removed the review/needs-review No maintainer or bot review yet label Jun 8, 2026
@mvvmm mvvmm changed the title WIP: Add image loading hints Add image loading hints Jun 9, 2026
@mvvmm mvvmm marked this pull request as ready for review June 9, 2026 00:34
@github-actions github-actions Bot added the review/needs-review No maintainer or bot review yet label Jun 9, 2026

@emdashbot emdashbot Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This PR adds fetchpriority="high" to the EmDashImage component when the priority prop is set, pairing it with the existing loading="eager" behavior. This is a focused, backwards-compatible performance improvement.

Approach: The approach is sound. fetchpriority is the standard HTML attribute for giving browsers a priority hint on image requests, and applying it only to images explicitly marked priority is the correct pattern. The author initially experimented with a data-early-lazy-load attribute on lazy images but wisely removed it in a follow-up commit, keeping the scope tight.

What I checked:

  • Read the full diff and every changed file.
  • Verified fetchpriority is only set when priority is truthy, and falls back to undefined (omitted) otherwise — consistent with established patterns in the codebase (e.g., target={blank ? "_blank" : undefined} in Link.astro).
  • Confirmed EmDashImage is the public Image component exported from emdash/ui, which is what theme authors use directly.
  • Reviewed sibling image components (Image.astro for Portable Text, EmDashMedia.astro, Gallery.astro, Cover.astro) and confirmed they either don't expose a priority prop by design (Portable Text blocks) or are outside the PR's stated scope.
  • Checked docs changes: the updated examples correctly switch from astro:assets to emdash/ui's Image, remove the non-existent featured_image_alt field, and add responsible guidance about using priority only for above-the-fold images.
  • Verified the changeset is present and correctly describes the change.

Conclusion: No logic bugs, no regressions, no AGENTS.md violations. The implementation is clean and the docs are accurate. LGTM.

@github-actions github-actions Bot added review/approved Approved; no new commits since and removed review/needs-review No maintainer or bot review yet labels Jun 9, 2026
{post?.data.featured_image && (
<Image
src={post.data.featured_image}
alt={post.data.featured_image_alt ?? ""}

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mvvmm Should we be concerned about dropping this line?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants