-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
Add/background image theme source #61401
Closed
Closed
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- get the theme directory URI, and - ensure background styles are parsed for theme.json and pattern/template files
…heme` both parent and child dir Update tests to check for image paths with leading slash Revert rogue tab
…ll url-like paths. Revert rogue space
Added/updated unit tests Bad horsie
…mage on the frontend.
…_file_uri (would be extracted into a new PR) Haven't worked out global styles yet. CSS rules might need to be injected into the DOM???
Feature complete, but hacky
Size Change: +730 B (+0.04%) Total Size: 1.74 MB
ℹ️ View Unchanged
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Follow up to #60578 to continue the discussion
Note
This PR is experimental and will be a reference for ongoing work. See #60578 (comment)
What? And How??!!!
Part of:
This PR proposes a way to add support for theme relative url paths for theme.json/templates/patterns by:
"source": "theme"
on the background image object in background supports, and appending the current theme path. It usesget_stylesheet_directory_uri
instead ofget_template_directory_uri
so that the path will reflect any active child theme.currentTheme
, that contains the current theme directory path. It also usesget_stylesheet_directory_uri
instead ofget_template_directory_uri
so that the path will reflect any active child theme.Why?
So that themes don't have to use global styles and rather, insert theme-relative paths into templates, patterns and theme.json.
This enhances portability of themes as Gutenberg will use the theme's current directory, regardless of install.
Testing Instructions
Assuming that
img/Untitled.jpg
exists in the theme dir, here's some test theme.json. Note only top-level background images are possible until #60100 gets in.Here's a test pattern (could also be HTML). Add it under
/patterns
in the theme directory:It should also work with templates. Add it under
/templates
in the theme directory:background-image
CSS value for both the frontend and editor.Testing Instructions for Keyboard