-
-
Notifications
You must be signed in to change notification settings - Fork 83
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
Largo-specific photo credit metadata is not output in image block #1683
Comments
This might be possible, via the server-side function https://developer.wordpress.org/reference/functions/render_block/ which would allow modifying the Here's what an image block's markup looks like: <!-- wp:image {"id":98709,"align":"center"} -->
<div class="wp-block-image">
<figure class="aligncenter">
<img src="https://example.test/wp-content/uploads/2018/01/TEDx3.png" alt="" class="wp-image-98709"/>
</figure>
</div>
<!-- /wp:image --> And here's what the output of <div class="wp-block-image">
<figure class="aligncenter">
<img src="https://example.test/wp-content/uploads/2018/01/TEDx3.png" alt="" class="wp-image-98709" srcset="https://example.test/wp-content/uploads/2018/01/TEDx3.png 731w, https://example.test/wp-content/uploads/2018/01/TEDx3-210x140.png 210w, https://example.test/wp-content/uploads/2018/01/TEDx3-336x224.png 336w" sizes="(max-width: 731px) 100vw, 731px">
</figure>
</div> Note the addition of srcset and sizes. |
Can we look at the list of |
@benlk So far it looks like we only have two options here other than regex.
|
Another option would be to use the block filters API and actually add the credit into the editor when the image is selected. |
That does sound better; it would avoid confusion between the editor depiction of the content and the frontend depiction. |
|
An update for this issue: It's pretty easy to replace the caption in the Gutenberg image block in the editor. All you need to do is enqueue a JS file for Gutenberg edits, load the correct elements, and do The hard part is grabbing metadata, which is where the media credit is stored. It doesn't look like you can choose what data to load for a block. Here's what you get back from
I suppose we could do a query to the WP API to grab the media credit? |
If querying the API works, let's do that. |
Querying the API works pretty well using something like this after registering the
The last thing I need to figure out is what filter to fire it on. Currently I have it set to |
Also, looks like there's no default way of achieving this sort of thing just yet: WordPress/gutenberg#8472 |
Maybe on blocks.getSaveElement? |
@benlk Probably something like that. |
To-do still:
|
Turns out you don't need to reload the page after saving, you just need to hang tight for a second. |
We should open a companion issue here for the Gallery Block, and whatever other image blocks Core provides that we'd want to use image credits for. We will also need to update the helpdesk docs for the changes introduced in #1733. |
@benlk Should that be one issue or two separate (one for gallery, one for everything else)? |
I think one for Gallery, one for Cover, one for Media and Text. Kinda taking the same approach as #1701 |
The media credit metadata added by the Navis Media Credit plugin (included in Largo) in https://github.com/INN/largo/blob/v0.6.1/lib/navis-media-credit/navis-media-credit.php isn't output on Gutenberg image blocks.
The text was updated successfully, but these errors were encountered: