1

How to allow authenticated users to see all versions of images but prevent anonymous users to see 'large' images created with an imagecache preset?

I've ticked the correct boxes under the permissions tab of imagecache so that anonymous users aren't able to see these images but still they show up. What am I doing wrong? (I've flushed the cache of the imagecache)

Cheers.

  • 1
    can you define "show up" and perhaps some more information/specifics? – Jimajamma Feb 7 '14 at 13:42
  • With 'show up' I mean that when the anonymous user clicks on the thumbnail Lightbox2 still shows the large image. Could it be that it's the lightbox2 permissions then or is it related to Imagecache? I'm not sure. – BassPlaya Feb 8 '14 at 4:53
  • I just checked and there are no permissions settings which prevent the viewing of certain Imagecache presets on Lightbox2. There are permissions in the Imagecache permissions section and none of them are selected for anonymous users. So I don't understand why they are able to see the 'original' size and all other sizes created by Imagecache. (pondering) – BassPlaya Feb 8 '14 at 5:01
0

A quick look through the imagecache module suggests that the only time the module itself enforces the "view imagecache [preset]" permission is when it is serving private files. This makes sense in that once the image derivative is created in the public files structure, it is never called; once a file "really exists" drupal is never bootstrapped up, it is only booted up to create the derivative the first time it's not found.

So, then, what are these permissions useful for? Well I'd imagine so you could do something like this...

$presets=array('small', 'medium', 'large');

foreach($presets as $preset) {
  if (user_access('view imagecache ' . $preset)) {
    // do whatever your module wants with that preset, create a link, show the image, whatever
  }
}

...in your own module.

As for lightbox2, a quick look there shows it just presents a list of possible Display Field options using all of the imagecache presets. As to why it doesn't check these permissions when building these links is a question for that module's maintainer on its issue queue on drupal.org.

  • Thanks Jimajamma! Much appreciated! However, I have no understanding really on how to create a module. I could possibly create a 'very' simple module but how to string things together.. no idea. Can you either help me out with this one or point me to a great resource (if possible related to permissions) so I can learn how to create my first actual 'useful' module? That'll be awesome. – BassPlaya Feb 9 '14 at 12:28
  • in the meantime I'll go ahead and read this: drupal.org/node/416986 – BassPlaya Feb 9 '14 at 12:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.