how to use images uploaded to public://
If $node-&gt;icon is the path relative to public://, then you can use the following code.

if ($wrapper = file_stream_wrapper_get_instance_by_uri("public://{$node-&gt;icon}")) {
  $url = $wrapper-&gt;getExternalUrl();
}


The code works also for stream wrappers that are not local, for which the file is not local to the server running the code.