You are here

protected function EntityShareMediasProviderAbstract::getRelativePathFromUrl in Entity Share 7

Get the relative drupal stream path from a full drupal URL.

Parameters

string $url: Url of the media.

Return value

string Relative path of the media.

1 call to EntityShareMediasProviderAbstract::getRelativePathFromUrl()
EntityShareMediasProviderAbstract::createFile in modules/entity_share_medias/includes/entity_share_medias.inc
Create the file.

File

modules/entity_share_medias/includes/entity_share_medias.inc, line 265
Class for handling Medias.

Class

EntityShareMediasProviderAbstract
Class EntityShareMediasProviderAbstract.

Code

protected function getRelativePathFromUrl($url) {
  $path = parse_url($url, PHP_URL_PATH);
  $path = explode('/', $path);

  // Remove filename.
  array_pop($path);
  $relative_path = array();
  for ($i = count($path) - 1; $i > 0; $i--) {
    if ($path[$i] == 'files') {
      break;
    }
    $relative_path[] = $path[$i];
  }
  $relative_path = implode('/', array_reverse($relative_path));
  return $relative_path;
}