I made a custom block in header that houses the following html along with 4 more of the same html for different social media sites:

a href="https://socialmediasite.com" target="_blank"
img src="/images/socialmedialink1_icon_32x32.png" alt="Social Media link" style="width: 32px; height: 32px; border:0"

The problems aren't the links because they do work. The problem is the images aren't showing up and only showing up as broken links so there's a problem with the img src link. I made a folder under root directory named images using my website hosting companies file manager and the images have been uploaded to that folder so I don't know what I'm missing. Am I missing something in the img src or something else before the a href or can it just not be done using only a custom block?

2 Answers 2


Try using the full site url for the src tags.

Prepend return value of $base_url and the rest of your path leading up to the image to your src attribute


exactly the problem is with you img tag src

global $base_path;
$themepath = $base_path.drupal_get_path('theme','theme_name');
$img_path = $themepath."/images/image_name.png"; 
$url = "https://socialmediasite.com";

$img =  "<a href='$url' target='_blank' class='class-name'><img src='$img_path' alt='Social Media link' style='width: 32px; height: 32px; border:0' /></a>";

print this where ever you want like

print $img; 

this is the way to get the image src dynamically it will be use full for moving your code from local to servers.

hope this helps :)


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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