When using Drupal 7 with the private download set as default, File Styles preview fails as the file is not accessible by the system.

If I do an "open image in new window" from the preview to check the image, you get an "Access Denied", I imagine because the image file is unmanaged and thus Drupal 7 cannot authorize it.

CommentFileSizeAuthor
file_styles_when_set_to_privaye.jpg43.35 KB3rdLOF
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

wjaspers’s picture

subscribe

wjaspers’s picture

Actually, it looks like the file_styles_variable_get() call is asking for a system variable that doesn't exist (preview_image_directory).

I took a peek over my database, and none of the variables requested in the code below are defined anywhere in the database.

Here's where I suspect the code is tripping up. file_styles.module line 80.

function file_styles_preview_image($replace = FALSE) {
  $path = file_styles_variable_get('preview_image');
  if (!$path || $replace) {
    $dir = file_default_scheme() . '://' . file_styles_variable_get('preview_image_directory');
    if (file_prepare_directory($dir,  FILE_CREATE_DIRECTORY)) {
      $source = file_styles_variable_get('image_style_preview_image');
      if ($path = file_unmanaged_copy($source, $dir . '/' . basename($source), FILE_EXISTS_REPLACE)) {
        file_styles_variable_set('preview_image', $path);
      }
    }
  }
  return $path;
}
TribalMan’s picture

I am seeing something similar. It appears that the module is trying to write to the wrong directory.

When File System is set to Private upload I get this problem. When set to public, there is no problem. If I look at the directories used by styles it has not written any "private" folders in its directories, only public... i.e. lots of write access errors

It keeps trying to write here

<img typeof="foaf:Image" src="http://www.mysite.co.za/?q=system/files/styles/square_thumbnail/private/image.jpg" alt="">

When it should be writing and reading here:

<img typeof="foaf:Image" src="http://www.mysite.co.za/?q=system/files/private/styles/square_thumbnail/image.jpg" alt="">
matrobin’s picture

subcribe