Skip to content

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

Closed

Description

@mcsf

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.

Activity

  1. added
    [Feature] Blocks
    [Feature] Media
    Backwards Compatibility
    [Feature] Shortcodes
    [Block] Gallery
    on Nov 6, 2018
  2. danielbachhuber commented on Nov 6, 2018

    @danielbachhuber
    Member

    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.

  3. mcsf commented on Nov 6, 2018

    @mcsf
    ContributorAuthor

    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?

  4. mcsf commented on Nov 6, 2018

    @mcsf
    ContributorAuthor

    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?

  5. danielbachhuber commented on Nov 6, 2018

    @danielbachhuber
    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.

  6. simison commented on Feb 12, 2019

    @simison
    Member

    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 :-(

  7. mcsf commented on Feb 12, 2019

    @mcsf
    ContributorAuthor

    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.

  8. simison commented on Feb 12, 2019

    @simison
    Member

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

  9. christinablust commented on Apr 16, 2019

    @christinablust

    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.

  10. added a commit that references this issue on Sep 8, 2020
    4ee28a0
  11. mcsf commented on Sep 8, 2020

    @mcsf
    ContributorAuthor

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

  12. added
    [Status] In Progress
    on Sep 8, 2020
  13. added a commit that references this issue on Sep 8, 2020
    f8a67f8
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Backwards Compatibility[Block] Gallery[Feature] Blocks[Feature] Media[Feature] Paste[Feature] Shortcodes[Status] In Progress

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions