You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Gallery: Transforming from [gallery] should fall back to Shortcode block. #11551
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.
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?
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 :-(
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.
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.
Activity
danielbachhuber commentedon Nov 6, 2018
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 commentedon Nov 6, 2018
I understood it to be:
[gallery ids=…]would yield a Gallery, and[gallery]a Shortcode.Did you mean Gallery?
mcsf commentedon 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 callcreateBlockwith whatever block type — essential to distinguishcreateBlock( 'core/gallery' )fromcreateBlock( '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 commentedon Nov 6, 2018
Yes, sorry. I've updated my comment.
simison commentedon Feb 12, 2019
This problem would get solved if the core gallery could define
isMatchin shortcode transform where it checks forids. Suppose it would then just fall back to shortcode block?That said, using
isMatchis broken or missing currently for shortcode transforms. #10674 :-(mcsf commentedon Feb 12, 2019
Yes, shortcodes are handled in a pretty different way. I can't tell for sure if
isMatchwould be the best interface for them, but it's worth checking, so thanks for opening that issue.simison commentedon Feb 12, 2019
Yup, suppose an alternative approach could be to define specific attributes as required with a possible list of accepted values.
christinablust commentedon Apr 16, 2019
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.Let ID-less [gallery] shortcodes fall to Shortcode block
mcsf commentedon Sep 8, 2020
There's a fix in #25144, if you'd like to test and review.
Let ID-less [gallery] shortcodes fall to Shortcode block (#25144)