1

I hope this is not a silly question. I have created some links to social media using images inside custom blocks. The images show up on every single page on my local testing server, but after uploading to my production server, I notice that on pages where I use URL aliases that are not directly attached to the site url, the images don't show up. For example if I the page address is www.thebeat99.com/sandbox/competitions, the images show up just fine. If the page address is www.thebeat99.com/sandbox/profile/dami, the images don't show up. I have tried adding a base url in the settings.php file but it does not work either.

This is an example of the html I use to embed the images:

<div class="beaticon" id="fbicon">
  <a href="http://www.facebook.com/thebeat999fm">
    <img alt="Facebook" height="32" src="sites/default/files/buttons/fbicon.png" width="15" />
  </a>
</div>
2
  • add few more information or code piece you used in the block to explain further Apr 23, 2015 at 11:29
  • I've updated the question with a sample of the code Apr 23, 2015 at 11:33

1 Answer 1

0

Add "/sandbox/" before sites like below (src="/sandbox/sites/default/files/buttons/fbicon.png")

<div class="beaticon" id="fbicon">
    <a href="http://www.facebook.com/thebeat999fm">
        <img alt="Facebook" height="32" src="/sandbox/sites/default/files/buttons/fbicon.png" width="15" />
    </a>
</div>

Or add "/" before sites as src="/sites/default/files/buttons/fbicon.png" and set your base url to http://www.thebeat99.com/sandbox

3
  • This worked for me. I'm wondering why though. So if I move it to a different server, I will have to rename all my links again. Is there a way that this works without changing every time I move the site. Thank you Apr 23, 2015 at 13:19
  • Never build urls explicitly: create them in code using the l() or url() functions. That's what they are for, to ensure portability. Apr 23, 2015 at 15:38
  • Your Drupal installation is inside the /sandbox directory. so better if you can use the base url as "thebeat99.com/sandbox" instead of the 1st option I mentioned. If you do it in that way follow the same folder structure in your local dev environment too.
    – ErangaJ
    Apr 24, 2015 at 3:18

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.