Can I specify random logos?

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:

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

<script>
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");
x=(Math.floor(Math.random()*numimages));
randomimage=(rndimg[x]);
document.getElementById("banner").style.logo-big = "url("+ randomimage +")";
}
</script>

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.

Thanks - Iโ€™ll give that a go :slight_smile:

Hi,

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

Best,
Michael

This is doable in a theme component, the method by @Alankrit_Choudh can work but I would recommend adding a custom ember initializer instead that overrides the URL in discourse instead of relying on window.onload here.

Sam,

์ €๋„ ๊ฐ™์€ ๋ฌธ์ œ์— ๋ถ€๋”ชํ˜”์Šต๋‹ˆ๋‹ค. window.onload๋Š” </head> ํƒœ๊ทธ ์ด์ „์— ํ˜ธ์ถœ๋˜๋ฉด ์ž‘๋™ํ•˜์ง€๋งŒ, ์ดํ›„์— ํ˜ธ์ถœ๋˜๋ฉด ์ž‘๋™ํ•˜์ง€ ์•Š์Šต๋‹ˆ๋‹ค. ๊ทธ๋ฆฌ๊ณ  ๊ทธ ๋•Œ๋ฌธ์— document.getElementById๊ฐ€ ์‹คํŒจํ•ฉ๋‹ˆ๋‹ค(์•„์ง ID๊ฐ€ ์ •์˜๋˜์ง€ ์•Š์•˜๊ธฐ ๋•Œ๋ฌธ์ด์ฃ ).

ember ๊ฒฝํ—˜์ด ์ „ํ˜€ ์—†๋Š” ์‚ฌ๋žŒ์ด ์ปค์Šคํ…€ ember ์ดˆ๊ธฐํ™” ํ”„๋กœ๊ทธ๋žจ์„ ๋งŒ๋“œ๋Š” ๋ฐฉ๋ฒ•์— ๋Œ€ํ•œ ์ž…๋ฌธ ์ž๋ฃŒ๋‚˜ ์˜ˆ์‹œ, ํŠœํ† ๋ฆฌ์–ผ์„ ์•Œ๋ ค์ฃผ์‹ค ์ˆ˜ ์žˆ์„๊นŒ์š”?

์ฐธ๊ณ ๋กœ, ์ œ๊ฐ€ ํ•˜๋ ค๋Š” ๊ฒƒ์€ URL ๋ฐฐ์—ด์—์„œ ๋žœ๋คํ•œ ๋ฐฐ๋„ˆ ์ด๋ฏธ์ง€๋ฅผ ํ‘œ์‹œํ•˜๋Š” ๊ฒƒ์ž…๋‹ˆ๋‹ค:

var jlmyPix = new Array(
     '/img/pic0.jpeg',
     [ ... ]
     '/img/picN.jpeg'
);

function jlchoosePic() {
     var jlrandomPicNum = Math.floor(Math.random() * jlmyPix.length);
     document.getElementById("jlmyPicture").src = jlmyPix[jlrandomPicNum];
};

window.onload = jlchoosePic;