How do I embed a URL in a block which is displayed as the linked image on the site?

2 Answers 2


For any source or path of any thing in drupal site use src like this. It will work everywhere.

<?php $src = base_path() .'sites/files/logo.png'; ?>

This src use like

<img alt="logo" src=" <?php echo $src ; ?>">

Enable PHP filter module that come with core module.

and in Block Body Choose Text format as PHP CODE.

I assuming block is created using Block module(Block UI)

  • Ah thank you! But got to ask - where does the base path begin? On the server of the site or in the base folder of the server? Yes I'm new to this... Immediately it just displays the code on the site rather than anything...
    – Ithxi
    Commented Apr 29, 2014 at 1:31
  • base_path() Returns the base URL path (i.e., directory) of the Drupal installation on server
    – Rupesh
    Commented Apr 29, 2014 at 1:34
  • So I write this: <img alt="logo" src=" <?php echo $src ; ?>"> $src = base_path() .'files/lightwater.jpg'; (tried the other way around as well) And this shows up in the block: "> $src = base_path() .'files/lightwater.jpg'; What am I doing wrong?
    – Ithxi
    Commented Apr 29, 2014 at 1:37
  • How to you build that block ? Any custom module, view, or Block UI?
    – Rupesh
    Commented Apr 29, 2014 at 1:59
  • Simply using the standard drupal 7 interface - no modules installed.
    – Ithxi
    Commented Apr 29, 2014 at 2:44

I found the answer - rather easy really.... the module Image Block solves the whole problem for those of you who might see this post asking yourself the same question!

EDIT The module simply creates an image block as said - it adds a "Add image block" to the block admin page. On the page you can choose to upload a picture - so you simply have to download the image from the URL and upload it in the block. Hence it does not exactly solve the problem but this is a workaround.

  • May you expand your answer to describe in which way those modules helped you?
    – apaderno
    Commented May 3, 2014 at 4:56
  • I simply forgot to write "module" in front of the name :-) Pardon
    – Ithxi
    Commented May 3, 2014 at 16:23
  • You should describe how you used the module to solve your problem. I understood you were speaking of a module; that is not the problem. :)
    – apaderno
    Commented May 3, 2014 at 16:41
  • Aight done - I had forgotten that you could only upload images to the block though... But it's a workaround for those with zero coding skills like me
    – Ithxi
    Commented May 3, 2014 at 20:35

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.