-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
Core blocks Image and Gallery should provide easy access to their data #8193
Comments
For |
I'll reply to @markfinst's items separately:
These are equivalent and just require us to switch away from sourcing Gallery and Image attributes in the HTML. It's technically an easy change and we can make that happen. I'll just note that I regret doing it, because it is a reflection of the current shortcomings in the server-side block API — ideally we wouldn't duplicate into the block boundary information that can be found in a block's HTML.
This is IMO a separate issue. I understand the need for it, but it's a little harder to prioritise it at the moment. Here's my perspective: WordPress attachment and attachment pages are very idiosyncratic concepts that have come to be to solve a very WordPress-specific set of problems — they allow developers to leverage the template hierarchy to overload the notion of attachments, effectively treating media items as CPTs in disguise, etc. This doesn't map very well to the editor-centric experience in Gutenberg, which arguably encourages different flows; I'm notably looking at reusable blocks to create "Attachment details" blobs, etc. I argued something very similar for ID-less galleries here. That's not to say we can't accommodate classic media attachments. Probably so, but I'd ask you to open a separate issue to discuss that, because I find it hard to prioritise that into WordPress 5.0. |
I see that you've commented about point no. 2 in #8310, so that issue is enough. |
Please dont: Do not separate native caption and alt from ... Native caption field is media component and their data. Gutenberg caption field is presenting media data in an article - caption related to the content. Editorial companies might using same image e twice, where in a "fader" for example, using saved caption (attachment excerpt) BUT within a post news article using the image with article related Gutenberg added caption. This is very important that Gutenberg doesnt cludder with attachment saved data! |
Text blocks, like paragraph and blockquote, can be styled just via CSS and would rarely need customizations of HTML markup.
Unlike text blocks, "Gallery" and "Image" might need advanced customization of HTML from the backend side.
Use cases
<img>
with<picture>
<img>
with entirely different markup for the purpose of lazy-loading.sizes
attribute for responsive images.Surely, all this would be applied by theme or by a plugin, so nothing should break when turning them on and off.
Current Status of Image Block
Stores attachment ID in JSON.
<!-- wp:image {"id":2253} -->
Which is good. But it does NOT store:
Current Status of Gallery Block
Gallery block does not store any data about images or their captions. The only way to retrieve it is to parse HTML via regex (specifically
data-id
attribute). Which is slow and unreliable.Solution Proposal
1. Store gallery attachment IDs in JSON
The Gallery should store an array with data about every image so it can be fully recreated on backend, specifically: attachment ID or image URL (if custom URL is added).
It should also use the same filters as
[gallery]
shortcode and gallery widget that was added to WordPress core recently.2. Do not separate native caption and alt from "Write caption" and "Textual Alternative" within Gutenberg
When editing Image caption in Gutenberg it should change the native WordPress Attachment "Caption" field too. Same for "Textual Alternative" (alt) option. They should also be named the same to avoid confusion.
3. Image Block - store Link URL option and Image Size option in JSON
Developer might need to recreate markup of image on backend.
Related issues
The text was updated successfully, but these errors were encountered: