ampproject / ampproject/amphtml

[amp-img] Support media features or dark mode

Open
#40,515 0 comments 0 reactions 0 assignees View on GitHub
Type: Feature Request
Dominant language
JavaScript
Stars
14.9k
Forks
4.1k
PR merge metrics
No merged PRs in 30d

Description

### Description

Without AMP, a dark mode version of an image can be set via `` like this:

```html


```

However, the `amp-img` component doesn't seem to have an option like that right now.

Maybe it could work in a similar way to the [fallback image](https://amp.dev/documentation/components/websites/amp-img#specify-a-fallback-image):

```html

```

### Alternatives Considered

Allow `media` to work like this:

```html

```

### Additional Context

_No response_

Contributor guide

Open the contributing guide

Research direction

Start by reading the amp-img component documentation, especially the existing fallback-image behavior, and compare it with the proposed nested amp-img and media examples. Determine which API should support dark mode or general media features, then define completion as documented, working behavior for the selected proposal without breaking the current fallback behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
frontend, web-dev
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.