Randomize Background Login Image

Random custom background on login. Want to change the links to an image file on a file host of your choice.

css

/* This code controls the background image .tb_classic
The Javascript tab has a random list of image URLs which will populate the image, if the Javascript is disabled by the client 
or too slow, the default image below will be used */

.tb_classic {
    background: var(--gray);
    background-image: url(https://static1.colliderimages.com/wordpress/wp-content/uploads/2025/07/king-of-the-hill-reboot-poster.jpg); 
    background-size: cover; 
    background-repeat: no-repeat; 
}

Javascript

/* Set a random background image on the login page.  The images are stored on a file host */

const images = [
    image1,
    image2
];

// Select a random image
const randomImage = images[Math.floor(Math.random() * images.length)];

// Apply the random image to the .tb_classic class
document.querySelector('.tb_classic').style.backgroundImage = `url(${randomImage})`;

/* End of login background custimization */

1 Like