Skip to content
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

Gallery: Transforming from [gallery] should fall back to Shortcode block. #11551

Closed
mcsf opened this issue Nov 6, 2018 · 9 comments · Fixed by #25144
Closed

Gallery: Transforming from [gallery] should fall back to Shortcode block. #11551

mcsf opened this issue Nov 6, 2018 · 9 comments · Fixed by #25144
Assignees
Labels
Backwards Compatibility Issues or PRs that impact backwards compatability [Block] Gallery Affects the Gallery Block - used to display groups of images [Feature] Blocks Overall functionality of blocks [Feature] Media Anything that impacts the experience of managing media [Feature] Paste [Feature] Shortcodes Related to shortcode functionality [Status] In Progress Tracking issues with work in progress

Comments

@mcsf
Copy link
Contributor

mcsf commented Nov 6, 2018

Quoting @danielbachhuber in #3852 (comment):

For [the 5.0 milestone], a standalone [gallery] shortcode would convert to a Shortcode Block. A [gallery ids="1,2,3"] shortcode would convert to a Gallery Block.

Ultimately, it doesn't appear we've yet come to a "good" option, only varying degrees of worse options. I don't think this UX is important enough to try to rush a decision on. Plus, we still have aspects like #5972 to deal with.

@mcsf mcsf added [Feature] Blocks Overall functionality of blocks [Feature] Media Anything that impacts the experience of managing media [Feature] Paste Backwards Compatibility Issues or PRs that impact backwards compatability [Feature] Shortcodes Related to shortcode functionality [Block] Gallery Affects the Gallery Block - used to display groups of images labels Nov 6, 2018
@danielbachhuber
Copy link
Member

danielbachhuber commented Nov 6, 2018

Transforming from [gallery] should fall back to Shortcode block.

Is this all instances of [gallery], or only instances without attributes (e.g. [gallery], but not [gallery ids="1,2,3"])?

At this point, because of #5972, I think we might as well not convert [gallery ...] to a Gallery Block at all.

@mcsf
Copy link
Contributor Author

mcsf commented Nov 6, 2018

I understood it to be: [gallery ids=…] would yield a Gallery, and [gallery] a Shortcode.

I think we might as well not convert [gallery ...] to a Shortcode Block at all.

Did you mean Gallery?

@mcsf
Copy link
Contributor Author

mcsf commented Nov 6, 2018

The only glitch is that the transformation API for shortcodes is different from the other ones (block, raw, files) in that it doesn't allow the consumer to provide a function that ultimately decides to call createBlock with whatever block type — essential to distinguish createBlock( 'core/gallery' ) from createBlock( 'core/shortcode' ).

@iseulde, do you remember if there was a motivation to keep the API for shortcodes different? Also, am I right in thinking that we currently can't proceed without tweaking the API?

@danielbachhuber
Copy link
Member

I think we might as well not convert [gallery ...] to a Shortcode Block at all.

Did you mean Gallery?

Yes, sorry. I've updated my comment.

@simison
Copy link
Member

simison commented Feb 12, 2019

This problem would get solved if the core gallery could define isMatch in shortcode transform where it checks for ids. Suppose it would then just fall back to shortcode block?

That said, using isMatch is broken or missing currently for shortcode transforms. #10674 :-(

@mcsf
Copy link
Contributor Author

mcsf commented Feb 12, 2019

Yes, shortcodes are handled in a pretty different way. I can't tell for sure if isMatch would be the best interface for them, but it's worth checking, so thanks for opening that issue.

@simison
Copy link
Member

simison commented Feb 12, 2019

Yup, suppose an alternative approach could be to define specific attributes as required with a possible list of accepted values.

@christinablust
Copy link

The specific issue I'm running into frequently on client sites (that led me to this ticket) is galleries using the [gallery id="7772"] syntax, where previously the gallery would go pull all photos attached to post id 7772. Currently "Convert to blocks" makes this an empty gallery, which is very problematic and loses a key piece of information (the other ID).

It would be much better to convert that use case to a shortcode and leave as is. Like mentioned up thread, some sort of conditional determination based on which attributes are used with [gallery] would be helpful here.

@mcsf
Copy link
Contributor Author

mcsf commented Sep 8, 2020

There's a fix in #25144, if you'd like to test and review.

@github-actions github-actions bot added the [Status] In Progress Tracking issues with work in progress label Sep 8, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Backwards Compatibility Issues or PRs that impact backwards compatability [Block] Gallery Affects the Gallery Block - used to display groups of images [Feature] Blocks Overall functionality of blocks [Feature] Media Anything that impacts the experience of managing media [Feature] Paste [Feature] Shortcodes Related to shortcode functionality [Status] In Progress Tracking issues with work in progress
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants