function url_to_realpath in Emogrifier 8
Same name and namespace in other branches
- 6 url_to_path.inc \url_to_realpath()
- 7 url_to_path.inc \url_to_realpath()
Returns an absolute local path corresponding to a given URL, if possible.
For example, when looking for image URLs within an email message body for possible conversion to inline attachments, the following code might be used:
if ( !url_is_external($url)
&& ($path = url_to_realpath($url))
&& file_exists($path) ) {
// Attach $path and replace $url.
...
}
Parameters
$url: The internal path or external URL being linked to, such as "node/34" or "http://example.com/drupal/foo".
Return value
FALSE if $url contains a host/port/path that does not match the current site, or else an absolute local path such as "/path/to/drupal/node/34".
See also
1 call to url_to_realpath()
- _emogrifier_process in ./
emogrifier.module - Implements hook_filter_FILTER_process().
File
- ./
url_to_path.inc, line 122 - Provide a url_to_path() function by refactoring and repurposing conf_path().
Code
function url_to_realpath($url) {
$path = url_to_path($url);
if ($path) {
return realpath(DRUPAL_ROOT . '/' . $path);
}
return FALSE;
}