[wp-trac] [WordPress Trac] #61273: Background image: add support for relative theme path URLs in top-level theme.json styles

WordPress Trac noreply at wordpress.org
Wed May 22 23:35:08 UTC 2024


#61273: Background image: add support for relative theme path URLs in top-level
theme.json styles
-------------------------+---------------------------------------
 Reporter:  ramonopoly   |      Owner:  (none)
     Type:  enhancement  |     Status:  new
 Priority:  normal       |  Milestone:  6.6
Component:  Themes       |    Version:  trunk
 Severity:  normal       |   Keywords:  has-patch gutenberg-merge
  Focuses:               |
-------------------------+---------------------------------------
 This is a ticket to track the syncing of the Gutenberg PR
 [https://github.com/WordPress/gutenberg/pull/61271 Background image: add
 support for relative theme path URLs in top-level theme.json styles ]

 === Background

 To ensure that themes with background image values in theme.json are
 portable — a theme developer can set a relative path to an image asset as
 a background image value, and that path will resolve correctly to absolute
 path of the file in the theme directory no matter where the theme is
 installed.

 Contrast this with absolute image paths: every installation of the theme
 would point to single image files sitting somewhere on the internet.

 === How

 Paths to images residing in the theme directory can be set in theme.son
 using the file: syntax, [https://developer.wordpress.org/themes/global-
 settings-and-styles/settings/typography/#registering-web-fonts-font-faces
 a convention already used in Core for web fonts].

 The path is relative to the theme root. For example:


 {{{
         "styles": {
                 "background": {
                         "backgroundImage": {
                                 "url": "file:./img/untitled.png"
                         }
                 }
         }
 }}}

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/61273>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list