WordPress / gutenberg

The Block Editor project for WordPress and beyond. Plugin is available from the official repository.
https://wordpress.org/gutenberg/
Other
10.29k stars 4.11k forks source link

Convert to Block replaces any Jetpack gallery with a default gallery #15134

Open gsallman opened 5 years ago

gsallman commented 5 years ago

Describe the bug Clicking on 'Convert to Blocks' on a pre-gutenberg posts converts Jetpack [gallery] shortcodes to a 'Guttenberg Gallery'. To reproduce Steps to reproduce the behavior:

  1. Create a post in the code editor with a couple of Jetpack rectangular (tiled mosaic) galleries.
  2. Switch to the visual editor
  3. Convert to Blocks
  4. The Jetpack Gallery code is deleted and replaced with the default Guttenberg Gallery function ruining the post's display.

Expected behavior on converting to blocks Gutenberg should create a classic block with the jetpack gallery shortcode in it.

Screenshots Original Post: image After converting to blocks: image

Desktop (please complete the following information):

Additional context

swissspidy commented 5 years ago

Sounds to me like Jetpack needs to provide a custom block transform to make this work. Gutenberg itself cannot know what Jetpack does with the gallery, so it's the plugin's the responsibility to provide that info IMHO.

gsallman commented 5 years ago

Sounds to me like Jetpack needs to provide a custom block transform to make this work. Gutenberg itself cannot know what Jetpack does with the gallery, so it's the plugin's the responsibility to provide that info IMHO.

That's one way of looking at it. I'd like to offer an alternative viewpoint.

The Convert to Blocks function shouldn't convert a Gallery shortcode to a Gallery Block if the shortcode has invalid parameters (That is invalid as far as the original Gallery shortcode is concerned). Gallery shortcodes with invalid parameters should be converted to a shortcode block so that the author can edit any errors in the parameters -- or leave it 'as is' if it is working as intended. The presence of the Jetpack Gallery 'type' parameter makes the shortcode an invalid Gallery shortcode.

If this approach is used then if a site has any plugins (Jetpack, third party or home-brewed) that replace the Gallery shortcode they will not be impacted (assuming they have additional parameters). whereas the current Convert to Block function takes a working post/page and messes it up.

The above approach is also good practice in terms of ensuring the data to be converted is valid before converting it.

talldan commented 5 years ago

This issue is being tracked in the jetpack repo: https://github.com/WordPress/gutenberg/issues/15134

simison commented 3 years ago

We need to add shortcode transform in Jetpack for Tiled gallery shortcodes: https://github.com/Automattic/jetpack/issues/11779

Originally we couldn't, because Gutenberg didn't have mechanism to differentiate between identical shortcodes based on attributes (lots of plugins used to just extend [gallery] shortcode, including Jetpack). That is now possible so just Jetpack side needs sorting.

I think this issue can be closed since there isn't really any action item for Gutenberg. Feel free to re-open if you think it's needed!

simison commented 3 years ago

The Convert to Blocks function shouldn't convert a Gallery shortcode to a Gallery Block if the shortcode has invalid parameters

On second thought, seems like a valid reason to keep this open.