I have a problem with Drupal uploads path when in a multi language site.
I have made a new language, and because the image’s source doesn’t have a backslash, it is not working.
My function uses the following code.
variable_get('file_public_path', drupal_get_path('theme', $theme) . '/uploads').'/';
If I use the following one, it works.
'/' . variable_get('file_public_path', drupal_get_path('theme', $theme) . '/uploads').'/';
It is a kind of ugly solution, and I bet there’s some more elegant way to deal with this.
The alternative to your code, to get the URL of an image that is saved in the public path is the following one. (Replace “image.png” with the correct file name.)
In your code, you need to use the slash at the beginning, otherwise the path is not considered relative to the server document directory.
Suppose that you enabled Italian as language for your Drupal site, the URL for the page is http://example.com/it/page, and the image is saved in sites/default/files/image.png. Without the slash, the image URL would be considered from the browser to be http://example.com/it/sites/default/files/image.png; using the slash, the image URL is considered from the browser to be http://example.com/sites/default/files/image.png.
As side note, the default value for the “file_public_path” Drupal variable should be
variable_get('file_public_path', conf_path() . '/files'. That is the default value used in system_file_system_settings().