I needed backgrounds with wallpaper patterns that you can seamlessly place next to each other, like these for example:


There are plenty of examples to be found if you search for something like ‘seamless pattern images’. If the license allows it, you can use them as a background for, for example, a Gutenberg Group block or Cover block. (In the settings dialogs for the background of these blocks, you can specify that the image should not be stretched but tiled next to each other, resulting in corresponding CSS background-size and background-repeat rules).
You might want to customize these kinds of patterns to your own taste: color, line thickness, shape, size of the repeated base element, etc. Of course, you can also draw/create something yourself in, for example, Illustrator or Inkscape (the latter is preferred due to the views on intellectual property that Adobe imposes on its users). There are also online generators available that produce these kinds of patterns (add the words ‘online generator’ when searching).
In any case, it would be better if you had this functionality within the WordPress block editor. Then you wouldn’t have to keep switching between the generator and WordPress, and you wouldn’t have to keep downloading and uploading patterns (and possibly exporting them to a usable format). This would also serve users who find all of this too cumbersome when they need new or customized patterns.
What is really desirable, then, is such an online SVG pattern generator, but as part of the Gutenberg editor. To achieve this, I went through several steps, starting with the background pattern below:
The pattern in the background of this frame is called Asanoha in Japanese, which means hemp. It doesn’t actually resemble a hemp leaf, but that doesn’t make it any less beautiful. And by the way, who really sees two fish in the constellation of the same name?
With this pattern in mind, I went through the following eight steps:
- Creating the SVG
- Creating JSON
- Passing JSON to the block editor
- Adding Functions that work with parameters
- Adding Inspector Controls to the Block Editor
- Creating a Renderer for Template, Parameters, and Function Results
- Presets
- Insert the SVG as a block background image
Finally, I created some additional patterns with different presets for the parameters. At the end, there is an overview of these.
1. Create SVG
2. Create JSON
3. Pass JSON to the Block Editor
4. Adding Functions
5. Add Inspector Controls to the Block-editor
6. Render template, parameters and functions
7. Presets
8. An SVG as a background
Patterns and Presets
Asanoha
Dark Night
Black River
Star Blazer
Soup
Beach
Red
Blue
Gump
Free
Crates
Metalic
Anatomy
Fragile
Ant
Diamond
Cardinal
Leaves
Polka
Candy
Rings
Elegant
Horrible 70
Awefull 80
Store
Seigaiha
Pink
Pink Gradiënt
Lime
Classic 2
Leave a Reply