Drupal - Page PHP prints images OK unless on admin / some user pages
Here is the code ive been us开发者_Python百科ing in my page.tpl.php:
<div id="beforefooter">
<?php print l('<img src="imagesmy/logo.jpg" />', '<front>', array('html' => TRUE)); ?>
</div>
<div id="afterfooter">
<a href="http://www.site.com" target="_blank" >
<img src="imagesmy/credit.jpg" />
</a>
</div>
For most pages this works fine, but when on an admin page the images dont show up. Also on certain user pages (that you need to be registered to see) the images also dont show up.
From looking at the source code on the page it seems identical when it does and doesnt work.
Thanks
Try using base_path()
or $base_path
print l('<img src="' . base_path() . 'imagesmy/logo.jpg" />', '<front>', array('html' => TRUE));
Are the paths to the image exactly the same on the different pages? I saw a similar problem where it was trying to find the image at "www.example.com/admin/imagesmy/logo.jpg instead of in the document root
You could also try constructing your image using drupal_get_path()
and it would be sure to resolve to the correct location for the image.
$img_path = drupal_get_path('theme', 'name-of-your-theme') . '/images/logo.png';
$img = theme('image', $img_path, 'the-alt-text', 'the-title-text');
print l( $img, '<front>', array('html' => TRUE));
精彩评论