I'm looking for a way how I can replace certain words for a specific image. For example: where ever I typ the word 'logo_purple' needs to appear the a specific image (logopurple.svg). Same counts for 'logo_white', 'logo_black', etc.
What is the best way to do this? These logo's can appear everywhere, but are the most common in Titles.
If there is a function in php (Something that I have to put in the functions.php? It's a Wordpress website) that can make this happen, I'll use that if jQuery won't work. I prefer jQuery.
Thanks in advance.
I've tried it like this: but for some reason, it breaks the toggleClass function (what I use for toggling my mobile menu).
var purple = "<img src='assets/images/logopaars.svg' />";
$("body:contains('zijn_paars')").html(function (_, html) {
return html.replace(/zijn_paars/g , purple )
});
var white = "<img src='assets/images/logowit.svg' />";
$("body:contains('zijn_wit')").html(function (_, html) {
return html.replace(/zijn_wit/g , white )
});
var black = "<img src='assets/images/logozwart.svg' />";
$("body:contains('zijn_zwart')").html(function (_, html) {
return html.replace(/zijn_zwart/g , black )
});
var pink = "<img src='assets/images/logoroze.svg' />";
$("body:contains('zijn_wit')").html(function (_, html) {
return html.replace(/zijn_roze/g , pink )
});