I am developing a drupal 7 site where 4 pages have url redirects from a parent page within the site. I have a block in the footer that is shown on all pages but the 4 pages mentioned above do not display the image within that block. I'm thinking that it must have something to do with the redirects as it is only these 4 pages that don't display the image. All other pages with that block show the image up just fine.
-
Well, most likely this image that is inside the block has a non-relative path? can you paste the block contents?– Pan ChronoCommented Jun 4, 2014 at 13:23
-
Here are the contents <div class="img-holder-getintouch"><img src="sites/default/files/footer-get-in-touch.png" alt="" width="250" height="291" /></div> etc.– kristin.eCommented Jun 4, 2014 at 14:08
2 Answers
In your situation a recommendation is to use relative path and not activate if this is your only reason the php as input type. Your code will be
div class="img-holder-getintouch"><img src="/sites/default/files/footer-get-in-touch.png" alt="" width="250" height="291" /></div>
You will see that i added just a slash as of this tells the site to request the file from http://www.example.com/sites.... this way you can do a migration and the images will still work.
-
Are u sure that the site is/will always be hosted on apache/server document root?? This will not be valis if thats the case.. Commented Jun 6, 2014 at 9:33
-
For more than enough situation this will be accepted solution. To activate php is also a solution but will involve some changes that is not necessary from the start. At the end user will decide what fit his need. Commented Jun 6, 2014 at 9:38
-
@Drupalizeme - Thanks for the extra slash advice - it worked a treat! Commented Jun 6, 2014 at 15:47
Well, this image will play nice only if you are in your homepage or something and then the relative path is as: http://site.com/sites/default/files/footer-get-in-touch.png
Off course this won't play for other paths as this is invalid
http://site.com/<PATH>/sites/default/files/footer-get-in-touch.png
Quick Solution:
Enable php filter module, to be able to write php inside the blocks contents and provide correct image path for all cases
<?php
global $base_path;
?>
<div class="img-holder-getintouch">
<img src="<?php echo $base_path; ?>sites/default/files/footer-get-in-touch.png" alt="" width="250" height="291" />
</div>