Skip to content

If we put image-related blocks in and save them, they lose their link with the part template. #448

Closed

Description

@megane9988

Description

Moves images to the assets folder when a block about images is included.
Also. Save a file called index.php in the part directory.

The link seems to be lost at this point.

<!-- wp:template-part {"slug":"header","theme":"foobar","area":"header"} /-->
↓
<!-- wp:template-part {"slug":"header","tagName":"header"} /-->

Step-by-step reproduction instructions

  • create blank theme from CBT
  • put the image block in index template
  • save as theme files to use CBT

Screenshots, screen recording, code snippet

video.mp4

Environment info

  • WordPress 6.3
  • Create Block Theme: 1.13.2

Activity

  1. pbking commented on Aug 29, 2023

    @pbking
    Contributor

    I believe what is happening in this scenario is this:

    • Because an image is in the template the content is converted to a PATTERN so that PHP referencing the image stored in the theme resources folder can be used.
    • The template that (in this case, and probably in most cases) that is converted contains a reference to a header TEMPLATE PART.
      This issue in Gutenberg outlines in what way that is problematic, however this change addresses that. So far this is only in Gutenberg though as this change hasn't yet made its way to CORE.

    Therefore the solution to this scenario is to EITHER:

    • Move the reference to the Header Template Part out of the resulting PATTERN and into the TEMPLATE.
      OR
    • Install Gutenberg plugin with this change (which I don't believe has been included in a released version yet).
      OR
    • Move the content of the HEADER Template Part into a PATTERN and reference THAT from the resulting pattern created by Create Block Theme

    I don't believe that this is a failing of Create Block Theme.

    NOTE: It might also be seen as a solution to include the 'theme' attribute on the Template Part block that is in the generated pattern. Indeed this WOULD make the content render. HOWEVER (as the linked issue details) this is NOT a valid solution if the theme is expected to be used in any environment other than where it was created. The 'theme' attribute MUST match the folder structure the theme is located in and this is not a guaranteed location.

  2. megane9988 commented on Aug 30, 2023

    @megane9988
    Author

    @pbking

    Thank you!!
    I have confirmed that the issue no longer occurs when using the Gutenburg plugin (16.5.1)!

    Do you want to leave this issue open until the main unit is fixed? Or is it better to close at this timing?

  3. pbking commented on Sep 6, 2023

    @pbking
    Contributor

    I believe we should close this as it isn't actually a problem with CBT.

    Thank you for confirming.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions