-
Notifications
You must be signed in to change notification settings - Fork 57
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
Bundle template images in theme assets and make their urls relative #192
Conversation
The download of the images and the inclusion on the new local theme or .zip file is working. So we would need to move the template's content to a pattern and then insert the pattern in the template. It sounds a little convoluted. Do you have a better idea of how we could do this? |
Here are some related GB issues: WordPress/gutenberg#31815 Perhaps it's worth looking into a token system like this: WordPress/gutenberg#42015 |
$media[] = $tag->getAttribute( 'src' ); | ||
$tag->setAttribute( | ||
'src', | ||
'<?php echo esc_url(get_template_directory_uri()); ?>/assets/images/'. basename( $tag->getAttribute( 'src' ) ) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this be
'<?php echo esc_url(get_template_directory_uri()); ?>/assets/images/'. basename( $tag->getAttribute( 'src' ) ) | |
'<?php echo esc_url(get_stylesheet_directory_uri()); ?>/assets/images/'. basename( $tag->getAttribute( 'src' ) ) |
🎉 What if we shipped with this feature, and worked on an easier way to make / save new patterns to the theme? It is a bit of a workaround but also solves something that is needed, which is an easier way to create patterns rather than copying and pasting the block markup into a new php file. Also I think it will be awhile before something like tokens is available. ---- EDIT My suggestion would not work yet. Because there is not yet a way to insert the pattern from the site editor and have it be preserved as a pattern — the full markup is inserted and stripped of any php, making it an absolute URL again. |
Is this and the pattern feature mentioned above, intended to be tested in the plugin and then moved to Gutenberg and then Core? is there a benefit to that over building it Gutenberg? |
71b4a2b
to
266b860
Compare
Currently, this seems to be the best possible way to achieve the bundling into the theme assets the images inserted into templates and template parts using the editor. The objective is to make this task easier for theme creators. I'm curious about how you imagine it working on Gutenberg. |
I'm closing this PR to continue the discussion on #213 to have a cleaner git diff. |
As part of the theme export functionality in the Site Editor, or did I misunderstand your question? |
Yep, it sounds like a good suggestion. I think first we can focus on make this functionality work in the plugin, test if it's handy and useful and after that kick-start a discussion about the addition to the Gutenberg theme export option. |
What?
If a template or a template part includes images which source is an absolute URL:
/assets/images
folder of the themeWhy?
To make the process of launching a theme easier by bundling to theme assets the images inserted using the editor.
To Do:
Include other blocks including images as cover.
How to test:
Closes: #161