I recently installed Drupal 8 to familiarize myself with this platform. I've noticed that, whenever I create an Article, and attempt to upload an image for that article, the styles created from that upload don't work and result in broken links.

The image uploads work just fine. Consider the image below: broken image derivatives screen

In the Article view under Add Content, I have uploaded a small 312 KB file.

  • The thumbnail preview (red) does not work here, nor elsewhere, and attempting to visit the link generated for this thumbnail results in a 403 Forbidden result: mysiteurl.com/sites/default/files/styles/thumbnail/public/2015-12/Untitled.gif?itok=Y40Z0DEa

  • The link to the image uploaded (blue) works just fine. Clicking that link displays the image: mysiteurl.com/sites/default/files/2015-12/Untitled.gif

  • Last detail: I see that this error extends to the Styles configuration screens as well, where the default image on the left side displays fine whereas the right-hand, style-applied preview is broken (and attempting to display the image in a new browser tab, just like the preview in the Article screen, results in a 403 Forbidden result).

styles error screen

How would I go about resolving this? I don't think it's GD, following the directions outlined in a troubleshooting page on Drupal (I cannot post more than two links, due to reputation) I see in the Configuration area for my site that I have a writable file system, and GD installed - bundled (2.1.0 compatible).

I may be coming from left field here, but might the 'Styles' directory be the culprit? If there's some way I can have this folder get regenerated by Drupal, I wonder if that would resolve these errors.

  • I would guess it is the permissions issue. Check if drupal can write into the styles directory. On the other hand the 403 should actually be 404. So that looks to me like the token is wrong but I'm just guessing and if that is the case I don't know how to fix the token(haven't explored that part of the core yet). Maybe change the hash_salt in settings.php? Really dunno.
    – user21641
    Dec 6 '15 at 11:20
  • You could also try this solution: drupal.stackexchange.com/questions/204008/…
    – MiSHuTka
    Jan 9 '17 at 13:26

Change the ownership of file folder to www-data:www-data and give permission to 755 in recursive way.

  • I strongly believe this is the issue. Dec 6 '15 at 18:36
  • Is your issue fixed or not by changing the ownership and permission? Basically this folder required such type of permissions so that drupal can create file and folder side this directory.
    – Prem Patel
    Dec 6 '15 at 18:47
  • Ah... Yes, I was applying that same access modifier value but not the recursive option. Doing so fixed the problem. Many thanks!
    – JLP1990
    Dec 13 '15 at 20:52

In your settings.php this is effective if permissions don't help:

$config['image.settings']['allow_insecure_derivatives'] = TRUE;
$config['image.settings']['suppress_itok_output'] = TRUE;

(Also check your log for entries on failing to make directories). There is some aggressive permissions block Drupal puts on derivative images partly because of possible DDOS attack vector. If you don't have many images though it doesn't matter much. The itok output line removes the token strings, which is needed if you call the images in unorthodox ways.

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.