Bruno Chavez
Bruno Chavez

Reputation: 193

How to get the right path to a image in Drupal 7?

I have tried to use the code bellow, but Its not working: ('test' is my subtheme )

 $image = file_directory_path() . "/sites/all/themes/test/images/brasil.png";

Upvotes: 0

Views: 57

Answers (1)

Nabil Kadimi
Nabil Kadimi

Reputation: 10414

File path

D7:

$image = DRUPAL_ROOT . "/sites/all/themes/test/images/brasil.png";

D6 and D7:

$image = getcwd() . "/sites/all/themes/test/images/brasil.png";

File URL

D6 and D7

global $base_url;
$image = $base_url . "/sites/all/themes/test/images/brasil.png";

Upvotes: 1

Related Questions