Skip to content
● Meet Grav Guard: keep every Grav site you run secure and up to date, all from one place. Free for up to 3 sites. Read more →

Rotate background image

Started by Richard Redcroft 9 years ago · 2 replies · 1648 views
9 years ago

Hi,
We are using the gateway theme, is it possible to have the background image be a random image?

Preferably a background image slider, is this possible?

Thanks

👍 1
9 years ago

Create a child theme and overwrite /templates/partials/header.html.twig in your child theme.

TWIG
.home-header-bg {
  background:url( '{{ theme_url }}/img/{{ site.header.background }}' ) #ffffff no-repeat center center fixed;
  -webkit-background-size: cover;
  -moz-background-size: cover;
  -o-background-size: cover;
  background-size: cover;
}

should be something like

TWIG
background:url( '{{ page.media.images | randomize | first }}' )

(not tested, no guarantee, but the direction should be correct.

👍 1
9 years ago

@Redsith:
Preferably a background image slider, is this possible?

You could use Vegas

Suggested topics

Topic Participants Replies Views Activity
Themes & Styling · by MarkP, 1 week ago
3 127 3 days ago
Themes & Styling · by TomW, 7 days ago
0 69 7 days ago
Themes & Styling · by themetman, 2 weeks ago
1 162 2 weeks ago
Themes & Styling · by AH, 4 weeks ago
1 278 2 weeks ago
Themes & Styling · by Bruno, 4 years ago
6 1467 2 weeks ago