I've got the private file system on because I need Drupal to be doing access control for media files. However, I can't seem to get avatars to display when it's set to private. They work when it's set to public.

It doesn't seem to work regardless of the upload directory being inside or outside public_html. The img tags are always showing the following source: //mydomain.com/system/files/pictures/picture-2.gif

Where is the /system coming from?? How can I fix this?

Comments

nathandigriz’s picture

function file_create_url($path) {
  // Strip file_directory_path from $path. We only include relative paths in urls. 
  if (strpos($path, file_directory_path()) !== false) {
    $path = trim(substr($path, strlen(file_directory_path())), '\\/');
  }
  switch (variable_get('file_downloads', FILE_DOWNLOADS_PUBLIC)) {
    case FILE_DOWNLOADS_PUBLIC:
      return $GLOBALS['base_url'] .'/'. file_directory_path() .'/'. str_replace('\\', '/', $path);
    case FILE_DOWNLOADS_PRIVATE:
      return url('system/files/'. $path, NULL, NULL, TRUE);
  }
}
stephthegeek’s picture

Okay... thanks... looks like that's where it's coming from. How do I get avatars working without breaking other stuff? I'm brand new to Drupal. I love it but I'm baffled that one of the two file systems wouldn't break something simple like this.

nathandigriz’s picture

Yes,
I know. I hope that someone can shed some light on this because it also breaks CAPTCHA and some other items. I thought that private would just effect downloads from a certain folder that I put in. But it does the whole system. The warning next to the setting keeps me from playing with it too much.

I am wondering if you can set it to public (system) and then use the filemanager module to set certain folders to private?

stephthegeek’s picture

I was testing out file download products in the Ecommerce module, and I used an avatar that was already uploaded as my test product. Since then, all avatars are suddenly working. I tested uploading a new one as well and it all seems to be fine.

I'm not sure what this would have changed (permissions on the dir? but I had chmodded it previously), but I thought I would post this mysterious resolution.