Chris Muench
Chris Muench

Reputation: 18318

drupal 7 link to theme image

This seems like a very basic question, but I have been googling around and can't get a good answer.

given sites/all/themes/phppos/img/demo.png

What is the CORRECT way to create an image take front page--front.tpl.php?

I have tried the below: (I get modules/system/img/demo.png)

<?php echo theme('image', array('path' => path_to_theme() .'/img/demo.png')); ?>

Upvotes: 1

Views: 5204

Answers (1)

nmc
nmc

Reputation: 8686

You're getting modules/system/img/demo.png as the resulting path because you're calling the path_to_theme() function within the theme() function.

According to the documentation for path_to_theme() :

...when invoked within the scope of a theming call it will depend on where the theming function is handled.

Try using drupal_get_path('theme', $theme_name) instead.

Upvotes: 1

Related Questions