Site logo

Archived topic

Preload background image

1 reply · Started by Anders Nielsen on June 11, 2021

Viewing posts 1–2 of 2

Is there a hook or something else I can do, so when I use background images – they will have a preload in the header?

But only a preload on that given page, where the background image is present.

Some automatic setup using hook, or something.,

Hi there,

simplest method is to not add the background image to the element in the customizer or editor.
You can use a Hook element to add to the wp_head to add the preload link and inline styles for adding the CSS to that element. Heres an example of the 'html' you could add to the do that.

<link rel="preload" as="image" href="full_url_to_the_image"/>
<style>.element { background-image: url('full_url_to_the_image');}</style>

Then set the Hook Display Rules for where you want it applied.

This archived topic is closed to new replies.