Skip to content

Custom layouts for gallery with registerBlockStyle() #69566

@jupa8712

Description

@jupa8712

Description

The gallery has only one layout option, which is using a grid and choosing the number of columns.

I was recently working on a project where the layout was a bit more complex, and I wanted to use gallery styles.

Everything worked perfectly on the front end, but in the backend, although the layout is visible correctly, the problem arises when I try to edit the gallery. When I select an image to change, the gallery becomes disorganized. This makes editing less intuitive.

This a video with the issue
https://www.youtube.com/watch?v=2U5drDwomxY

This is caused by a div that is always added after the selected image.

Image

I don't quite understand why that div is added, but it would be nice if it didn't affect the custom designs we can create.

Step-by-step reproduction instructions

  1. Create a gallery
  2. Create a custom grid css for gallery
  3. Try to update some image

Screenshots, screen recording, code snippet

https://www.youtube.com/watch?v=2U5drDwomxY

Environment info

No response

Please confirm that you have searched existing issues in the repo.

  • Yes

Please confirm that you have tested with all plugins deactivated except Gutenberg.

  • Yes

Please confirm which theme type you used for testing.

  • Block
  • Classic
  • Hybrid (e.g. classic with theme.json)
  • Not sure

Metadata

Metadata

Assignees

Labels

[Block] GalleryAffects the Gallery Block - used to display groups of images[Block] ImageAffects the Image Block[Status] In ProgressTracking issues with work in progress[Type] BugAn existing feature does not function as intended

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions