How to display an image from theme directory to a drupal block by php code? I want to load an image from my theme directory inside a block. I am using the following code:

&lt;img src="&lt;?php print $base_path .$directory; ?&gt;/images/oil-ad.png" alt=''oil ad"&gt;.


But it is not working. However I have enabled PHP Filter and php text format.
In your image "alt" attribute, you have 2 single quotes before oil ad and a single quotation mark following it. That syntax doesn't look right to me. Maybe THAT is causing some error somehow? If not then read on below for further narrowing down your issue.

Assume you used admin/structure/block/add to create that block, with a "body" in which you added that img tag.

When doing so, you also need to select the "text format" (below the body) to be used. You wrote you used "php text format", though I'm assuming you mean "test format"="PHP code".

To further ivestigate where your problem is actually coming from, try to further narrow down your issue. By FIRST creating such image tag without using any PHP code. And instead use some text format like 'Full HTML' and/or 'Filtered HTML', something like so (I intentionally did not correct the syntax of the alt attribute, because that might produce the error you're searching for ...):

&lt;img src="/some/path/that/is/hardcoded/images/oil-ad.png" alt=''oil ad"&gt;.


If that works then have a confirmation that your issue is NOT because of some text format configuration issue related to using the "img" tag.