Drupal Answers is a question and answer site for Drupal developers and administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a custom logo and I have tried to get his path in this way theme_get_setting('logo_path'), but no expected result.

I am using the code in a custom block, in input PHP.

share|improve this question
Where are you using this code? Have you tried theme_get_setting('logo_path', 'THEME_NAME'), replacing THEME_NAME with the name of your theme? – marcvangend Mar 21 '11 at 13:21
up vote 7 down vote accepted

logo_path seems to only be set if you override the theme's default logo via its theme settings. To get the default logo, use theme_get_setting('logo').

share|improve this answer
But why the result of theme_get_setting('logo') is empty string ? I have set my custom logo in /admin/appearance/setting – Ek Kosmos Mar 21 '11 at 13:53
Why when Logo is deactivate from theme TOGGLE DISPLAY - Enable or disable the display of certain page elements. the theme_get_setting('logo') has no results. Why ? – Ek Kosmos Mar 21 '11 at 14:28
Thanks, that's exactly what I was looking for! Use <a href="<?php echo theme_get_setting('logo');?>"> in a PHP code block to show the logo in your own block. – Coomie Dec 2 '14 at 8:39
global $base_url;

if (!$logo = theme_get_setting('logo_path')) {
    $logo = theme_get_setting('logo');

if (!empty($logo)) {
  // [1]
  // Remove the base URL from the result returned by theme_get_setting('logo').
  // If you don't need the relative path, you can remove this code.
  if (strpos($logo, $base_url) === 0) {
    $logo = drupal_substr($logo, drupal_strlen($base_url));
  // [1]
  // …

The call to drupal_theme_initialize() is not strictly necessary, and it doesn't do anything if the global variable $theme is already initialized.
The code is removing the base URL because the value reported from theme_get_setting('logo') is an absolute path; if you don't need a relative path to access the file, then the part between // [1] can be removed.

When the logo has been disabled in the theme settings, theme_get_setting('logo') doesn't return anything.

share|improve this answer
I replaced the code in [1] with $logo = file_create_url($logo); in order to get the full URL path of the logo (with the http://). – Matt Fletcher Aug 5 '14 at 10:15

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.