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

Image and Media & Text blocks: Use LinkControl #50893

Open
5 tasks
richtabor opened this issue May 23, 2023 · 12 comments
Open
5 tasks

Image and Media & Text blocks: Use LinkControl #50893

richtabor opened this issue May 23, 2023 · 12 comments
Labels
[Block] Image Affects the Image Block [Block] Media & Text Affects the Media & Text Block [Feature] Link Editing Link components (LinkControl, URLInput) and integrations (RichText link formatting) [Focus] Accessibility (a11y) Changes that impact accessibility and need corresponding review (e.g. markup changes). Needs Dev Ready for, and needs developer efforts [Type] Enhancement A suggestion for improvement.

Comments

@richtabor
Copy link
Member

richtabor commented May 23, 2023

Part of #50891

As part of the effort to consolidate the link application experience across the editor #50891, let's use LinkControl to apply links to the core/image and core/media-text blocks as well. It may be useful to have LinkControl depict what controls render when in a media context (like these two blocks).

Tasks

  • Implement LinkControl within the Image block.
  • Implement LinkControl within the Media & Text block.
  • Add a method for LinkControl to render media-specific actions at the foot (above "Add new page").
  • Do not render "Text" input field when in media-specific context.
  • Add support for "Class" input field in the link settings drawer when in media-specific context (supporting existing feature-set).

Visual

Current Proposed
CleanShot 2023-05-23 at 15 34 14 CleanShot 2023-05-23 at 15 33 55
@richtabor richtabor added [Block] Image Affects the Image Block [Block] Media & Text Affects the Media & Text Block [Feature] Link Editing Link components (LinkControl, URLInput) and integrations (RichText link formatting) labels May 23, 2023
@richtabor richtabor mentioned this issue May 23, 2023
13 tasks
@getdave
Copy link
Contributor

getdave commented May 25, 2023

I'd love to see if we could utilise the rich preview idea to display a preview of the media you've selected if it is an image. That's a stretch goal though...

@carolinan
Copy link
Contributor

Do not render "Text" input field when in media-specific context.

What does this text input field do?
Because linked images need to have a link text, and usually this is the alt text, so it is visually hidden.
But the link text needs to be editable because it describes the link target, not the image.

@richtabor
Copy link
Member Author

What does this text input field do?

There’s not one. Text field is for the copy that the link is applied to.

@afercia
Copy link
Contributor

afercia commented May 26, 2023

Re: @carolinan's point: see also #50950 (comment)

@getdave
Copy link
Contributor

getdave commented May 26, 2023

Adding a setting to control the alt text is a good idea. I'm assuming however, that we'll want this to be one of the "primary" fields shown next to the URL field rather than hidden in the settings? I ask because I'll likely be implementing it and I want to consider how I architect this.

@richtabor
Copy link
Member Author

richtabor commented May 26, 2023

I'm not sure about a manually input alt text field that overrides the image's alt text field (something to explore a bit more on though). But I do think we could perhaps auto-apply an alt text for the attachment page or image file link options (if there is no alt text for the image) as suggested here: #50950 (comment)

That's interesting. It would be nice to auto-set the Image block's alt text if "Link to attachment page", or Link to image file" options were selected. Would be a nice follow-up to explore.

@getdave
Copy link
Contributor

getdave commented Sep 15, 2023

I don't think this will land in 6.4.

@richtabor richtabor moved this from Needs Dev / Todo to Punted to 6.5 in WordPress 6.4 Editor Tasks Sep 15, 2023
@richtabor
Copy link
Member Author

I don't think this will land in 6.4.

Agreed. Punted.

@afercia afercia added the [Focus] Accessibility (a11y) Changes that impact accessibility and need corresponding review (e.g. markup changes). label Sep 18, 2023
@afercia
Copy link
Contributor

afercia commented Sep 18, 2023

Adding a setting to control the alt text is a good idea. I'm assuming however, that we'll want this to be one of the "primary" fields shown next to the URL field rather than hidden in the settings?

The alt text is the actual text content. As such, it should be in a prominent spot in the UI. In the core media grid, we moced the Alternative Text field to the top since a while, because it's the most important field.

I'm not sure about a manually input alt text field that overrides the image's alt text field (

That's what WordPress does everywhere iwth alt text since ages. Always provide users with the ability to adapt the alt text to the specific usage in the current context.

But I do think we could perhaps auto-apply an alt text for the attachment page or image file link options (if there is no alt text for the image) as suggested here: #50950 (comment)

I don;t think I'm actually suggesting to auto-apply an alt text in that comment? What I pointed out there is that when an image is linked, the alt text must describe the link purpose / destination. Often, the alt text saved in the media gallery only describes the image content, which would be inappropriate for a link.

That's interesting. It would be nice to auto-set the Image block's alt text if "Link to attachment page", or Link to image file" options were selected. Would be a nice follow-up to explore.

Not sure that would work appropriately. For example:

  • I add an image to a normal post, and I link the image to its attachment page. It's a link so the alt text must describe the link destination or purpose.Something like: Go to the White Unicorn image details page.
  • When in the attachment page, the auto-set alt text would still be Go to the White Unicorn image details page, which is clearly wrong.

Unfortunately, WordPress foesn't provide the ability to set multiple atl text to be used in different context, so far. There have been some discussions in that regatd but no actual action plan. For this reason, I'd think the beast option for now is to always provide users with the ability to set the alt text manually.

Cc @joedolson @alexstine for any welcome additional thoughs.

@richtabor
Copy link
Member Author

In the core media grid, we moced the Alternative Text field to the top since a while, because it's the most important field.

What's this?

For clarity, I was referring to the alt text on the link itself, which we do not currently support (image, nor the media-text block), not the image's alt text.

@carolinan
Copy link
Contributor

There seems to be some confusion about the link text for linked images, where the image is the only element inside the link.

I was referring to the alt text on the link itself,

A link, an <a> element, can not have an alt attribute, it is not valid HTML.
If the image has an alt attribute, the alt attribute is the accessible name.
If the link has an aria-label, the aria-label is the accessible name, not the alt.

@carolinan
Copy link
Contributor

Besides linking to the image media file and attachment page, the media & text block needs to be able to link to the current post in a query loop when the featured image is used.

It can be useful to always be able to link to the current post when inside a query loop, not only for the media blocks, so I think this should be added as an option.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Block] Image Affects the Image Block [Block] Media & Text Affects the Media & Text Block [Feature] Link Editing Link components (LinkControl, URLInput) and integrations (RichText link formatting) [Focus] Accessibility (a11y) Changes that impact accessibility and need corresponding review (e.g. markup changes). Needs Dev Ready for, and needs developer efforts [Type] Enhancement A suggestion for improvement.
Projects
None yet
Development

No branches or pull requests

5 participants