Change logo based on incoming domain

The agency I work for are trying to get a client’s logo to change based upon the incoming URL.

Now, we have 4 different URLs, therefore 4 different logos.

Currently, we are using an if/else statement, though we keep getting the alt text as opposed to the image. The image source is definitely correct.

if(!empty($image)) {
     echo '<h1>WEBSITE_NAME_HERE</h1>';
 } else {
    echo '<img src="'.logoSwap().'" alt="Localised Logo">';
}

For the function that has been declared (logoSwap()), we are using this code in the functions.php file:

<?php
function logoSwap(){
switch($_SERVER['HTTP_HOST']) {
    case 'WEBSITE_URL_HERE.com': 
        $logo = "WEBSITE_URL_HERE/wp-content/uploads/2016/01/logo-red.png";
    break;
    case 'www.WEBSITE_URL_HERE.com':
        $logo = "WEBSITE_URL_HERE/wp-content/uploads/2016/01/logo-red.png";
    break;
    case 'WEBSITE_URL_HERE.co.uk':
        $logo = "WEBSITE_URL_HERE/wp-content/uploads/2015/09/logo.png";
    break;
    case 'www.WEBSITE_URL_HERE.co.uk':
        $logo = "WEBSITE_URL_HERE/wp-content/uploads/2015/09/logo.png";
    break;
    default:
        $logo = "WEBSITE_URL_HERE/wp-content/uploads/2015/09/logo.png";
    break;
};}
?>

The trouble is, only the alt tag is feeding through.

Localised Logo Alt Tag

Is there somewhere specific I should be putting the second PHP script? Am I not calling to the logo correctly?

We are using a Themify theme, so I am not sure whether that will throw a spanner into the works.

Any help is much appreciated.

0

Leave a Comment