0

I set a URL alias for one of my content type pages. So now every 'newsroom' content type is at http://myurl.com/newsroom/name-of-article. That's perfect. But that page also has blocks that contain images and now the paths to those images are broken.

my block contains: scr="sites/default/files/mobile-nav.png"> but the page is trying to find the image at src="NEWSROOM/sites/default/files/mobile_nav.png"

The block that contains the image is on every page of the site because it's the mobile nav.

How do I change my url alias? Or what do I need to do to tell drupal how to find the images correctly while keeping the image path relative?

1

src="sites/default/files/mobile-nav.png"> should be src="/sites/default/files/mobile-nav.png">

Please note the additional "/" before "sites." Without the forward slash the image will always be called from wherever you're at on the site so if you were at say site.com/news/ it would look for the images in site.com/news/sites/default.... if you don't have the forward slash before sites.

0

You should try to keep your code independent from your base path, so that if later on your install path changes to a subdirectory or another domain, paths will still work. Try this:

<?php global $base_path; ?>
... src="<?php print $base_path; ?>sites/default/files/mobile-nav.png"

$base_path contains the path to the Drupal installation (at least a "/" - see Drupal docs for details). Notice that it must be declared as global before use.

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.