Hi,

I have media gallery enabled in a fresh Drupal 7.7 installation that is set to use a private file system path and *private* as a default download method. When I create a media gallery and I add images, the images seem to be uploaded, but no thumbnails are displayed. If I try to "view the larger image" by clicking on the space in the thumbnail placeholder lightbox displays the images normally.

Looking into the private path, I see that the original images are uploaded and the folder styles/media_gallery_large/private is created and filled with the images that I have previously viewed via lightbox, but the styles/media_gallery_thumbnail/private is missing (i.e., no thumbnails are created) and I get the error message below (in the log):

Type	access denied
Location	.../system/files/styles/media_gallery_thumbnail/private/1.jpg
Referrer	.../node/4
Message	system/files/styles/media_gallery_thumbnail/private/1.jpg

Any help in solving this would be greatly appreciated!

Thank you!

Comments

onny’s picture

subscribe, I'm getting this bug too.

brightyman’s picture

I see the same issue and would really appreciate a fix.

Thank you.

Moloc’s picture

Some other modules handle the file_download hook in a wrong way.
If you use the Webform module, try updating it to the latest stable release. (See #1283456: webform_file_download query does not check that file is owned by Webform)
If you use the CKEditor module, try updating to the latest dev release. (See #1343310: [D7] Change settings for private download and #1324990: [D7] Access to private file (download) problems)

Does this fix your issues with access denied?

crifi’s picture

This issue is maybe related to #1223670: Media declared private no longer visible: Site broken in the media module.

ursula’s picture

I am having the same issue with media_gallery. I don't have webform or CKEditor installed.
The originally uploaded images are managed in the table file_managed, and have an entry like the following:

+-----+-----+--------------+------------------------+------------+----------+--------+------------+-------+
| fid | uid | filename     | uri                    | filemime   | filesize | status | timestamp  | type  |
+-----+-----+--------------+------------------------+------------+----------+--------+------------+-------+
|  71 |   1 | P1050372.jpg | private://P1050372.jpg | image/jpeg |   177049 |      1 | 1334603309 | image |
+-----+-----+--------------+------------------------+------------+----------+--------+------------+-------+

media_gallery.module has a function that, according to the comments and its name, deals with private files and permissions (media.pages.inc: function media_download). However, when using a xhprof and debug, I realized that the function never gets called.

I actually got it to work by changing the image module, which I tried because the type is "image".
I posted the details in the image issue queue (http://drupal.org/node/1438940#comment-5878636)

crifi’s picture

Version: 7.x-1.0-beta6 » 7.x-1.x-dev
Status: Active » Closed (duplicate)

I still think this is a duplicate of #1223670: Media declared private no longer visible: Site broken because the patch there fixes in my case this issue here. Please test the patch before reopening.

ursula’s picture

I tested the patch, it didn't fix my problem, I guess because the type was "image" and not "media".

crifi’s picture

Currently I don't understand how you use media_gallery without the media module as dependency. Maybe this isn't a duplicate of #1223670: Media declared private no longer visible: Site broken if you use media_gallery without media file types. Please specify the bug a bit more, because I think the original report isn't the same as yours.

ursula’s picture

Sorry for the late reply.

I am using media_gallery with the media module as dependency. However, in the table "file_managed", the filetype is not stored as "media" but as "image". That's why the previous fix didn't work, and I am using my workaround (http://drupal.org/node/1438940#comment-5878636), which is basically hacking core (hacking, because it's not a proper fix).

Using now Drupal 7.14, and newest versions of media and media_gallery. Problem is still there.
When I have some time, hopefully this weekend, I'll test whether a change in the database table to filetype "media" will fix the problem.

Waichai’s picture

How are you, all? I have similar issue but not relating to media gallery. My case is not always bad. I am using a image field to upload images and those are being stored in sub-folders in private folder. The thumbnails displayed in the nodes are always fine and also their original sizes after clicking to enlarge. The only problem is the display after query sorting by the views. Most of the time, 90 of 100 times, the thumbnails in the views are fine. I mean all the thumbnails are displaying normally in majority cases. The ten is that thumbnails are not able to show normally. Sometimes thumbnail A works fine but sometimes not. As well, B works well but another sometimes not. In these abnormal cases, there maybe half amount of thumbnails showing fine but another half not.
If anyone can help, it would be very appreciated.

Remark: another drupal sites I am storing the images in public folder are always working fine. Never with this problem.

Taxoman’s picture

Status: Closed (duplicate) » Postponed

ok, so per #9, this issue is not resolved, I suggest keeping this open until we see if the coming resolution to #1223670: Media declared private no longer visible: Site broken actually helps this issue too.

Staler75’s picture

hi,

i have the same problem, but with public files :(
on linux servers there are no problems, but i`m now setting up a site on a windows based server and have this problem now, realy need a solution asap, because my customer need the site with gallery

any help is appreciated.

flogator’s picture

Same here. I can get Media Gallery working fine with public file system but the thumbnails are not generated using private file system. I did a bit of digging and the problem is not necessary with the Media Gallery module itself. I do not pretend I have found the problem but hopefully, some hints as to where the problem is.

I ended up modifying the Image core module. In the file .../modules/image/image.module in the function image_style_deliver(), there is a piece of code that says "if ($scheme == 'private')". That code seems to handle private files in a different way. I do not understand the rationale here but it seems to me that this piece of code is trying to invoke a hook that is not defined by the Media Gallery. I do not understand why private files should be getting a special treatment there.

Long story short, I have replace "if ($scheme == 'private')" by "if ($scheme == 'FIXMEprivate')" and thumbnails are now working for Media Gallery. This is obviously not a fix. However, I'm hopping the author of Media Gallery can determine if there is a missing implemented hook in his module (which I don't think). If there are no missing implemented hook, I think this bug should be punt in the Image module.

vvaidy’s picture

I hit the same problem and can confirm that flogator's "fix" at #13 worked for me as well.

Avitohol’s picture

Hello, is there any progress on this topic?
I have a fresh install containing:
Drupal core 7.17
Media 7.x-1.2
Media Gallery 7.x-1.0-beta8
Chaos tool suite (ctools) 7.x-1.2
Multiple forms 7.x-1.0

The problem in case the method is set to private is still the same, and as I must have it private, I can't have any galleries at all.

Lehtóri’s picture

I encountered the same problem with a D7.19
#13 'fixed' it for me aswell.

codemode01’s picture

1 vote up for Fix #13! Thanks flogator.

...which begs the question as to why we don't have an option to vote comments like flogator's up to the top of this post to make it immediately available for developers and generally frustrated/confused solution hunters... like myself. If there's any agreement with this idea, maybe re-post it the next time you find yourself scrolling through 100 comments to find the best fix.

SocialNicheGuru’s picture

This is a big issue. It was solved for D8: https://drupal.org/node/2027423 but the patch has not been ported
There was a hack/fix (THANK YOU FOR IT) here:https://drupal.org/comment/6419804#comment-6419804

yet another issue: https://drupal.org/node/2027423

alamp’s picture

Issue summary: View changes

+1 vote up for Fix #13!

My error code is as follows, to make it better googled for other potential D7 users.

May  5 18:12:30 X <Warning>: http://localhost/gee|1399309950|access denied|::1|http://localhost/drupal/system/files/styles/thumbnail/private/imagefield_uTFfWu.jpeg?itok=FPbrQiVi|http://localhost/drupal/|1||system/files/styles/thumbnail/private/imagefield_uTFfWu.jpeg

Here is the patch from #13

diff --git a/modules/image/image.module b/modules/image/image.module
index c6a23f2..b2ede61 100644
--- a/modules/image/image.module
+++ b/modules/image/image.module
@@ -828,7 +828,7 @@ function image_style_deliver($style, $scheme) {

   // If using the private scheme, let other modules provide headers and
   // control access to the file.
-  if ($scheme == 'private') {
+  if ($scheme == 'FIXMEprivate') {
     if (file_exists($derivative_uri)) {
       file_download($scheme, file_uri_target($derivative_uri));
     }
SocialNicheGuru’s picture

I needed to make the change above to FIXMEprivate and I had to add the following and it seemed to work:

$conf['image_allow_insecure_derivatives'] = TRUE; 

http://drupal.stackexchange.com/questions/63226/drupal-7-20-image-styles...

ivnish’s picture

Status: Postponed » Closed (outdated)