Suppose I have a module mymodule. In mymodule forlder I have a folder with images, in this folder I have images img1.jpg, etc.
How to get the url of these images?
drupal_get_path('module', $module_name);
The easiest way, as mentioned above, is to use the relative path to the root of the site:
'/' . drupal_get_path('module', $module_name) . '/img1.jpg'
Using this without a trailing slash at the beginning will split it into several level aliases, for example. http://www.your_site.dev/category/2012/11/02/
// path drupal_get_path('module', $module_name) . '/images';
file_create_url (drupal_get_path ('module', $module_name)). '/'; >
To get the correct URL for your image, you need to add base_path()at the beginning of your image path. Valid URL:
base_path()
$url = base_path() . drupal_get_path("module", "MY_MODULE") . "/image.png";