Skip to content
Grav 2.0 is officially stable. Read the announcement →

Community guidelines

Please keep discussions civil and on-topic. Repeated violations may lead to a temporary ban.

Themes & Styling

Rotate background image

Started by Richard Redcroft 9 years ago · 2 replies · 1165 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
8 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 Pedro M, 2 months ago
4 197 2 months ago
Themes & Styling · by Ian, 2 months ago
3 92 2 months ago
Themes & Styling · by Norbert, 2 years ago
11 454 3 months ago
Themes & Styling · by Lukáš Findeis, 3 months ago
0 47 3 months ago
Themes & Styling · by Sebadamus, 4 months ago
5 127 3 months ago