1

I'm working on a set of similar websites (promoting products of different regions) separated by Domain Access module. I'd like to set different default image in an image field in each site. Is it possible?

1 Answer 1

0

Point the image to a .php file instead of a .jpg file, and then write a script to

  1. Find the domain name (https://stackoverflow.com/a/17201254/836995)
  2. Output the appropriate image (https://stackoverflow.com/a/1353867/836995)

Something like this should work (untested):

<?php

$img_file = NULL;

switch ($_SERVER['SERVER_NAME']) {
  case "www.a.com":
    $img_file = "filename_a.jpg";
    break;
  case "www.b.com":
    $img_file = "filename_b.jpg";
    break;
  default:
    break;
}

if (!empty($img_file)) {
  header("Content-type: image/jpeg");
  readfile($img_file);
}

This is a bare minimum script. A more elaborate version here: https://stackoverflow.com/a/9453207/836995 (although you don't need the .htaccess part to do this for only one image).

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.