It would be handy if this warning included a link to the media library to add alt text to the file:
There may be a more elegant way to do this, but you could add a class to <img> tags containing the image ID using the hook wp_get_attachment_image_attributes:
Then you could extract that ID using some Javascript and use it to link straight to the media library by just slotting the ID into the URL: /wp-admin/post.php?post=<id>&action=edit.
This would not be 100% bulletproof since images in the block editor only pull alt attributes out of the media library when initially added to a post, but anything in the block editor is already easy to access using the edit link in the toolbar, and having this shortcut would make adding alt attributes to other sources like featured images just as quick.
Interesting. I'll explore in the summer/fall sprints. Since I build my interface dynamically I should be able to just include that data in my JSON (note to self) without modifying the DOM.
It would be handy if this warning included a link to the media library to add alt text to the file:
There may be a more elegant way to do this, but you could add a class to
<img>
tags containing the image ID using the hookwp_get_attachment_image_attributes
:Then you could extract that ID using some Javascript and use it to link straight to the media library by just slotting the ID into the URL:
/wp-admin/post.php?post=<id>&action=edit
.This would not be 100% bulletproof since images in the block editor only pull alt attributes out of the media library when initially added to a post, but anything in the block editor is already easy to access using the edit link in the toolbar, and having this shortcut would make adding alt attributes to other sources like featured images just as quick.