0

When calls theme's style.css file with add_editor_style inside gutenberg, background images are not loading properly.

Lets say:

#intro {
    background: url(assets/main.png) ;
}

Its working properly on front-end like:

mydomain.com/wp-content/themes/mytheme/assets/main.png

But when in gutenberg, WordPress tries to load:

mydomain.com/wp-admin/assets/main.png

Am i missing something?

2
  • Is there a reason you do not want to set the full relative path in style.css? Have you tried #intro { background: url('/wp-content/themes/mytheme/assets/main.png') ;}
    – Anthony D
    Jan 9, 2020 at 14:47
  • It can be in subfolder installation Jan 10, 2020 at 15:06

1 Answer 1

0

You can load the css via PHP instead ,

add_action('wpmm_head', 'wpmm_custom_css');

    function wpmm_custom_css(){
     echo '<style>
           #intro{
    '.get_template_directory_uri().'/assets/main.png;
           }
           </style>';
    }
1
  • You can't always know all images tbh. This is a problem that needs automatic fix Jan 13, 2020 at 8:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.