Can I specify random logos?

(AstonJ) #1

Is it possible to (via a plug-in if necessary) randomly choose a logo (and small logo) from a set of 3 every time someone starts a new session (or until their browser refreshes the assets for the logo)?

The Ruby code is trivial - but how can we incorporate that into Discourse? :confused:

(@SenpaiMass) #2

You could do it with JS i suppose, here is code i hope it works

if (document.getElementById) { window.onload = swap };
function swap() {
var numimages=4;
rndimg = new Array("IMAGE URL 1", "IMAGE URL 2", "IMAGE URL 3", "IMAGE URL 4");
document.getElementById("banner").style.logo-big = "url("+ randomimage +")";

PS this only works on hard refresh. also the css to big logo would be

.logo-big { 
background-image: url('DEFAULT LOGO IMAGE URL HERE');

The JS would work because i am using that to rotate my banner image randomly on every hard refresh not sure the exact code for logo CSS.

Help us test our new post rendering engine!
(AstonJ) #3

Thanks - I’ll give that a go :slight_smile:

(Michael Smart) #4


This is exactly what I need! Is the second part required? Also where does the first part get put exactly?