I am using a content type with Image type fields to hold images uploaded to a web site. I want to display these images both on distinct pages (easy) and inline on other pages (almost even easier).

However, I don't want to expose /sites/default/files/ in the image URL, and I certainly don't want to include it in the image tag's src attribute when I refer to the image from some other page.

How do I include at an arbitrary location on an arbitrary page an image uploaded like that, without exposing the physical directory structure in the link? I tried using the URL aliases feature provided by the Path module, but it wouldn't let me point to anything in /sites as such.

  • 1
    What problem is having /sites/default/files/ in the image URL causing you? Knowing that might help to understand the problem a bit better – Clive May 26 '13 at 20:38
  • @Clive It isn't an actual problem right now because this particular Drupal installation only hosts one site, but if I want to consolidate multiple sites within a single Drupal installation, I can easily see it becoming a problem (file name collisions, differentiating between files from different sites, ...). – a CVn May 27 '13 at 9:15
  • In a multisite files will be underneath the respective site's folder though (sites/site1.com/files, sites/sites2.com/files) so there's no chance of a collision there – Clive May 27 '13 at 12:30

You could create a symlink in the drupal root using:

ln -s sites/default/files images

and then set the src attribute to something like:


Really not sure what you would gain by doing this.


You can use .htaccess and mod_rewrite. Like described on stackoverflow. In my opinion it's the cleanest solution, but other ones may still be valid.

Then, in your template.php you need to rewrite rendered image addresses to reflect new ones.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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