Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Duotone doesn't work with Media & Text block #32972

Open
OlaIola opened this issue Jun 24, 2021 · 4 comments
Open

Duotone doesn't work with Media & Text block #32972

OlaIola opened this issue Jun 24, 2021 · 4 comments
Labels
[Block] Media & Text Affects the Media & Text Block [Type] Enhancement A suggestion for improvement.

Comments

@OlaIola
Copy link

OlaIola commented Jun 24, 2021

Description

Duotone works with Image block but with Media & Text block it isn't working.

Expected behaviour

Duotone is supposed to work with all images (at least JPG and PNG).

Actual behaviour

2021-06-24_23-11-56

WordPress information

  • WordPress version: including 5.8 Beta 3
@Mamaduka Mamaduka added the [Block] Media & Text Affects the Media & Text Block label Jun 25, 2021
@github-actions github-actions bot added the [Status] In Progress Tracking issues with work in progress label Jun 25, 2021
@thisissandip
Copy link
Contributor

PR added: #32984

@thisissandip thisissandip removed the [Status] In Progress Tracking issues with work in progress label Jun 25, 2021
@thisissandip thisissandip removed their assignment Jul 8, 2021
@jordesign jordesign added the [Type] Enhancement A suggestion for improvement. label Aug 17, 2023
@ajlende
Copy link
Contributor

ajlende commented Aug 24, 2023

Copying over #32984 (comment) for easier reference as to why this hasn't been completed and the workaround that can be used.

The media and text block doesn't support duotone because it allows for video elements with controls, and the SVG filter applies to the video controls as well causing contrast accessibility issues. (See #26361 (comment))

If you want to have a duotone image next to text, I'd suggest using columns to arrange the image and text side-by-side.

@mrwweb
Copy link

mrwweb commented Nov 16, 2023

I would like to nudge this issue now that doing this has become harder in recent versions of WP.

Previous to 6.4 (or possibly 6.3?), I was registering a custom block style (e.g., .is-style-xxxxx-duotone { filter: var(--wp--preset--duotone--xxxxxxx) }) that referenced the matching SVG duotone filter. This method no longer reliably works, because duotone SVGs are only output on posts where a block is using that duotone filter. If my Media & Text block is the only block on that post that needs the filter, the SVG and custom property are not available.

I've switched to to inlining the SVG in the custom block style, but that is far from ideal. If it helps unblock this issue, I'd be quite happy if the duotone option was only available on Media & Text blocks using images rather than videos. I would think that can be detected, but I admittedly don't know.

Example of workaround for now

register_block_style(
	'core/media-text',
	array(
		'name' => 'newspaper-duotone',
		'label' => __( 'Newspaper Duotone', 'textdomain' ),
		'inline_style' => '.wp-block-media-text.is-style-newspaper-duotone .wp-block-media-text__media { filter: url(\'data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg"><defs><filter id="wp-duotone-newspaper"><feColorMatrix color-interpolation-filters="sRGB" type="matrix" values=" .299 .587 .114 0 0 .299 .587 .114 0 0 .299 .587 .114 0 0 .299 .587 .114 0 0 "></feColorMatrix><feComponentTransfer color-interpolation-filters="sRGB"><feFuncR type="table" tableValues="0.1921568627451 0.89019607843137"></feFuncR><feFuncG type="table" tableValues="0.1921568627451 0.89019607843137"></feFuncG><feFuncB type="table" tableValues="0.1921568627451 0.89019607843137"></feFuncB><feFuncA type="table" tableValues="1 1"></feFuncA></feComponentTransfer><feComposite in2="SourceGraphic" operator="in"></feComposite></filter></defs></svg>#wp-duotone-newspaper\') }',
	)
);

@mrwweb
Copy link

mrwweb commented Jun 24, 2024

I just had a client request this because it seemed obvious to them that if they could duotone an image, they should be able to duotone it with Media & Text. Given that Columns + Image wouldn't include the same responsive behavior or focal point picker, that's also not a viable workaround in many (most?) cases.

the media and text block doesn't support duotone because it allows for video elements

I want to first say that I ❤ the concern for accessibility. That is unambiguously good. To avoid the issue, maybe duotone support can only apply for the block with images? My gut says that wouldn't be that hard.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Block] Media & Text Affects the Media & Text Block [Type] Enhancement A suggestion for improvement.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants