• Resolved ulim

    (@ulim)


    I’ve noticed that if I create a background image in a header, then it is not created as an HTML element. The URL is only present in the CSS like so:

    [data-header*="type-1"] .ct-header [data-row="top"]
    --background-image: url(http://localhost/wordpress/wp-content/uploads/2020/05/mybackground.jpg);

    This leads to problems when changing the site’s URL or, as in this case, migrating from localhost to the production server. The usual migration tools do not pick up on URLs in stylesheets, they only search the database.

    So I wonder if it would make sense for you to store those values in the database instead of in the stylesheet?

Viewing 2 replies - 1 through 2 (of 2 total)
  • Theme Author Creative Themes

    (@creativethemeshq)

    @ulim Those values are stored in the database (in theme mods in most cases, to be specific) in the first place. It’s just that we generated a global.css file upon customizer save based on those DB values. So, if you’d run your usual search/replace tool against the DB then just save the customizer once — the stylesheet will be in sync again with the right URLs (or just run do_action("customize_save_after") which will be picked up by the dynamic CSS generator.

    Important aside: The above is only relevant if you use the File strategy for CSS output, which is only present when you also use the Blocksy Companion plugin. If you don’t use the Companion, just run the search/replace against the DB then do a page refresh — you’ll see the right URLs right away.

    Hope this helps. Please let us know if you still don’t manage to get updated URLs somewhere and we’ll be in touch.

    Thread Starter ulim

    (@ulim)

    Yes, I use the File strategy. Thank you very much for the explanation how things work. This is completely fine for me, if just saving the Customizer will regenerate the global.css file.

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘Background Image in Header in CSS’ is closed to new replies.