It’s possible to have CleanSlate generate a random image, file, or blog article. This can be useful for changing background images on a hero element, getting a random blog post to display on your site’s homepage, or for getting a random page from within your site. CleanSlate will generate a new random image, file, or blog article every 30 seconds.

Get a random image based on a label:

As an image tag in HTML:

<r:files:each labels="my-label" limit="1" types="image" random="true">
  <img src="<r:file:image_url />" alt="<r:file:alt_text />">
</r:files:each>

…Or inline as a random background image on a div:

<div class="my-div" style="background-image: url(<r:files:each labels="my-label" limit="1" types="image" random="true"><r:file:image_url /></r:files:each>);"></div>

You can also do this in a style attribute in the head and even have CleanSlate generate different sizes of the image from a loop.

Get a random blog post

<r:blog:articles:each limit="1" random="true">
  <r:article:name />
<r:blog:articles:each>

Get a random page

<r:siblings:each limit="1" random="true">
  <r:page:name />
</r:siblings:each>

This can be used in any loop using r:children, r:siblings, r:descendants and r:ancestors.


Last updated on June 12, 2017.

We welcome all questions, feedback and bug reports. If you're having an issue, we usually need the following information:

  • A brief description of the issue
  • A link to the page where you saw the issue
  • Screenshots that illustrate the problem - How do I take a screenshot?

Kindly email CleanSlate@mail.wvu.edu for help or use the form on the request help page.