0

In some cases, I am entering some text and an img src tag in descriptions and text fields on my content pages rather than use an image field, for example the Header field on a view.

I cannot work out the location to use. I thought images/imagefilename.jpg would do the job, but alas no. I also want to avoid the old http://hostname.com/images/imagefilename.jpg for vairous reasons.

My images are in themes/mytheme/images.

2

Unless the location of your Drupal install changes (sub directory versus root directory), the easiest way would be to use a relative path from the site root to the image.

<img src="/sites/all/themes/mytheme/images/imagefilename.jpg" />

You could get the file path with a PHP snippet. Note that the PHP filter module needs to be enabled, and the PHP code text format selected, for this to work.

<?php $path = base_path() . path_to_theme() . '/images'; ?>
<img src="<?php print $path; ?>/imagefilename.jpg" />
0

Typically your images would live in your /sites folder, especially under a theme.

The two most common paths would be:

or

Depending on whether you are using a site-specific folder or the all folder to host your themes folder.

The easiest way to determine the correct path would be to mimic the path for the css files also in your theme folder and included in the http header when viewing the rendered html source in a web browser.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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