The mystery of the disappearing image...

Events happening in the community are now at Drupal community events on www.drupal.org.
Posted by DeeZone on January 4, 2009 at 2:59am

Has anyone had the issue of an image appearing on one page node and not on another? I have a case where the image:

http://dev5.playpoi.com/sites/playpoi.com/themes/playpoi_NEXTGEN_v02/ima...

appears here:

http://dev5.playpoi.com/about-poi with:

[画像:Only local images are allowed.]

but not any of the sub nodes such as here:

http://dev5.playpoi.com/about-poi/why-poi
http://dev5.playpoi.com/about-poi/poi-history
etc. with:

[画像:Only local images are allowed.]

Looking at the pages with Firebug the CSS assignment looks identical as well.

The odd thing is that it's the same template file: page-about-poi.tmp.php for all of the pages. This can be confirmed with the presence of in the HTML source of each page within the tag.

Everything appears the same and yet the image will not display on the sub pages.

Comments

base_path ?

Posted by markus_petrux on January 4, 2009 at 8:09am

How do you build the path to the image?

print $directory

Posted by DeeZone on January 4, 2009 at 9:03am

Via block-views-about_poi.tpl.php

<img width="170" height="48" border="0" src="<?php print $directory ?>/images/navBarRightBlock_RedTail.jpg" alt="" />

This is consistent between both cases, one that works and one that fails to display the image.

Try with $base_path before $directory ?

Posted by markus_petrux on January 4, 2009 at 9:52am

<?php print $base_path . $directory ?>

Freak show!

Posted by DeeZone on January 4, 2009 at 4:27pm

Markus,

Thanks for the suggestion, I've setup:

<div class="content">
<?php print $block->content ?>
1.<img width="170" height="48" border="0" src="<?php print $base_path . $directory ?>images/navBarRightBlock_RedTail.jpg" alt="" />
2.<img width="170" height="48" border="0" src="<?php print 'http://' . $_SERVER["SERVER_NAME"] . '/' . $directory ?>/images/navBarRightBlock_RedTail.jpg" alt="" />
3.<img src="http://dev5.playpoi.com/sites/playpoi.com/themes/playpoi_NEXTGEN_v02/images/navBarRightBlock_RedTail.jpg" />
4.<img width="170" height="48" border="0" src="<?php print $base_path ?><?php $directory ?>images/navBarRightBlock_RedTail.jpg" alt="" />
5.<img width="170" height="48" border="0" src="<?php print base_path() . path_to_theme() ?>/images/navBarRightBlock_RedTail.jpg" alt="" />
</div>

Here: http://dev5.playpoi.com/about-poi and http://dev5.playpoi.com/about-poi/poi-history the results are still surprising but at least they're consistent.

The resulting HTML is:

1.<img width="170" height="48" border="0" src="sites/playpoi.com/themes/playpoi_NEXTGEN_v02images/navBarRightBlock_RedTail.jpg" alt="" />
2.<img width="170" height="48" border="0" src="http://dev5.playpoi.com/sites/playpoi.com/themes/playpoi_NEXTGEN_v02/images/navBarRightBlock_RedTail.jpg" alt="" />
3.<img src="http://dev5.playpoi.com/sites/playpoi.com/themes/playpoi_NEXTGEN_v02/images/navBarRightBlock_RedTail.jpg" />

4.<img width="170" height="48" border="0" src="images/navBarRightBlock_RedTail.jpg" alt="" />
5.<img width="170" height="48" border="0" src="/sites/playpoi.com/themes/playpoi_NEXTGEN_v02/images/navBarRightBlock_RedTail.jpg" alt="" />

Sadly what I would expect and what you've suggested is the one solution that fails. img tag 1. and 4. don't load while the other three hacks do. I'm going to go with number 5... odd but at least it works.

base_path()

Posted by markus_petrux on January 4, 2009 at 7:11pm

Oh, if $base_path is not available under the context your template is being executed, then base_path() should do the trick. Sorry for not mentioning this before.

$base_path + base_path()

Posted by renyi on July 29, 2010 at 5:34am

Took me 4 hours to find this >.<" You're the only one to mention this in all the posts I looked at. Thank you.

Context?

Posted by DeeZone on January 4, 2009 at 7:43pm

Markus,

Could you point me in the right direction to understand what the considerations are for "the context your template is being executed". Are there PHP/Drupal settings I should be aware of?

Source code itself?

Posted by markus_petrux on January 4, 2009 at 8:11pm

Template files have a preprocessor function that build the variables available to templates. For example, for page-tpl.php, you can look at modules/system/page.tpl.php, that contains a lot of information about the available variables in its own source code, but those are prepared in function template_preprocess_page located in includes/theme.inc, which would be a better source if the template file was not documented.

When you see a function named theme_xxxx, there may also exist a function named template_preprocess_xxxx, or module_preprocess_xxxx (where 'module' is the name of the module that implements the theme function). In case of doubts, if not already documented in the module README or similar, you may contact the module author.

In the case of views, you have a lot of information in the sources as well, in the theme subdirectory of the views installation, or you can install the advance_help module that also provides information about views theming, or look at the views developers group.

Thank you...

Posted by DeeZone on January 4, 2009 at 8:42pm

Markus,

You're a wealth of information. It's people like you that make working with Drupal so rewarding. Thanks!

Theme development

Group organizers

Group notifications

This group offers an RSS feed. Or subscribe to these personalized, sitewide feeds:

AltStyle によって変換されたページ (->オリジナル) /