-
Notifications
You must be signed in to change notification settings - Fork 82
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 gallery block refactor #106
Comments
What is the format when links are used? |
<!-- wp:gallery {"linkTo":"none"} -->
<figure class="wp-block-gallery blocks-gallery-grid has-nested-images columns-default is-cropped"><!-- wp:image {"id":141,"sizeSlug":"large","linkDestination":"custom"} -->
<figure class="wp-block-image size-large"><a href="https://www.google.com"><img src="https://s.w.org/images/core/5.8/nature-above-01.jpg" alt="Image gallery image" class="wp-image-141"/></a></figure>
<!-- /wp:image -->
<!-- wp:image {"id":139,"sizeSlug":"large","linkDestination":"custom"} -->
<figure class="wp-block-image size-large"><a href="https://www.apple.com"><img src="https://s.w.org/images/core/5.8/nature-above-02.jpg" alt="Image gallery image" class="wp-image-139"/></a></figure>
<!-- /wp:image --></figure>
<!-- /wp:gallery --> The nested image blocks should behave the same same as a standalone image block in terms of how the attributes are set. |
Uh, I guess I was thinking when the image is linked to the media file or the attachment page. |
My apologies, ignore the above examples they are a little confusing due to some bad copying and pasting on my part, the following hopefully gives a better indication of how the linking works with the new gallery format <!-- wp:gallery {"linkTo":"attachment"} -->
<figure class="wp-block-gallery blocks-gallery-grid has-nested-images columns-default is-cropped">
<!-- wp:image {"id":242,"sizeSlug":"large","linkDestination":"attachment"} -->
<figure class="wp-block-image size-large"><a href="http://localhost:4759/2021/08/30/106/3-2/"><img src="http://localhost:4759/wp-content/uploads/2021/08/3-2.jpeg" alt="Image gallery image" class="wp-image-242"/></a><figcaption>Some trees</figcaption></figure>
<!-- /wp:image -->
<!-- wp:image {"id":241,"sizeSlug":"large","linkDestination":"custom"} -->
<figure class="wp-block-image size-large"><a href="https://www.google.com/"><img src="http://localhost:4759/wp-content/uploads/2021/08/Zr6yoV-1.jpeg" alt="Image gallery image" class="wp-image-241"/></a><figcaption>More trees</figcaption></figure>
<!-- /wp:image -->
<!-- wp:image {"id":230,"sizeSlug":"large","linkDestination":"custom"} -->
<figure class="wp-block-image size-large"><a href="http://www.apple.com"><img src="http://localhost:4759/wp-content/uploads/2021/08/images-2-26.jpeg" alt="Image gallery image" class="wp-image-230"/></a></figure>
<!-- /wp:image --></figure>
<!-- /wp:gallery --> With the above the gallery block has a default 'linkTo' set of 'attachment' and the first Image block is inheriting this, but because the gallery is now made up of nested Image blocks it is possible for an individual image to override the gallery setting and define its own link, so above the next two images have defined their own custom links
As noted above, the gallery may have not defined a link option, but images within the gallery can be set to their own custom links. Hopefully this makes more sense, but get back to me if not. |
It's not clear from this issue - what change needs to be made to the importer specifically? The importer doesn't alter the imported post content, aside from performing a string replacement on the old Attachment URL with the new attachment URLs, and even then it does a relatively poor job at it.. If I were to guess, perhaps we need to change the |
It looks like this is irrelevant as the importer doesn't directly manipulate gallery block content in any way it seems, so closing. |
A major refactor of the Gutenberg core gallery block was recently merged which uses innerBlocks instead of nested
img
elements in the block content.This new gallery format is currently behind an experimental feature flag (probably until mid September due to some mobile app backwards compat issues). Even after the flag is removed the old gallery format will still be accepted by the editor, so I don't think there is any panic for the importer to be modified to handle this, but just alerting you to the change so you can plan for adding handling of it.
The existing Gallery block format is as follows:
and the refactored format is:
The text was updated successfully, but these errors were encountered: