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

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

Closed
megane9988 opened this issue Aug 24, 2023 · 3 comments

Comments

@megane9988
Copy link

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
@pbking
Copy link
Contributor

pbking commented Aug 29, 2023

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.

@megane9988
Copy link
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?

@pbking
Copy link
Contributor

pbking commented Sep 6, 2023

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

Thank you for confirming.

@pbking pbking closed this as completed Sep 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants