5

I am struggling to find a solution for image styles not getting generated. The original pictures get uploaded to the server but no styles or thumbnails are generated.

I have checked folder permission and set it to 775 and even 777 (temporarily) for the /styles/ and its subfolders.

I even set $conf['image_allow_insecure_derivatives'] to TRUE.

Yet I still get access denied for the anonymous users (not verified when I upload images and no styles or thumbnails).

Any suggestions are greatly appreciated.

4

Drupal version 8.5.3 Local dev with Aquia Dev Desktop.

I've tried all combinations with .htaccess (root, in /files and in styles) with no success.

Also tried with:

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

No results.

Even though I had a settings.local.php solution was to uncommment this line in settings.php:

$settings['file_public_path'] = 'sites/default/files';
2

I have spent more than 48 hours looking for a solution for a Drupal 8 site and I have finally SOLVED it. I have tried any possible nginx config suggested everywhere, including this and the one found here. Also checked any possible permissions issues on files and folders on the whole project to no avail...

What I found is that when uploading an image the system never got to write it to the image style folder... I discovered this when I created a new image style I realised the folders for that image style created correctly and the demo image was placed correctly as well.

Hinted by another user I turned my efforts to the temporary folder which drupal passes images through to generate image styles. I found that I have accidentally set a temporary folder within drupal filesystem, the setting was: temp in Configuration > File system > Temporary directory. This folder probably had wrong permissions and maybe it was the linux t permission also known as sticky bit that drupal needed for this. When I changed the temp folder location to /tmp (I'm on centos) image styles worked like a charm again immediately!!

Hope this helps someone...


Update

I run into this problem again, but the solution was a bit different. If the above does not work for you and you use nginx, make sure you have the correct nginx directives which can be found here: https://www.nginx.com/resources/wiki/start/topics/recipes/drupal/

2

By adding this line in setting.php this problem will be resolved and image will appear.

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

I also had problems with image styles not generating and it turns out it was because mod_rewrite wasn't enabled in my apache2. Hope it helps someone

1

I've tried this /tmp folder trick and it didn't work for me; what did though is this: In .htaccess file in /sites/default/files folder i've changed this:

Options -Indexes -ExecCGI -Includes -MultiViews

to this

#Options -Indexes -ExecCGI -Includes -MultiViews
Options +SymLinksIfOwnerMatch

Have no idea if it has a security issue or anything else, since i'm total zero in this things, but it worked :) Well, I also have all the folders in /sites/default/files 775'd, including files itself.

UPDATE #1! Actually, only commenting the first line like this

#Options -Indexes -ExecCGI -Includes -MultiViews

works for me, so one of those options standing on our way to image styles. I don't know exactly which one, please feel free to play with them.

UPDATE #2! Actually, the update #1 works only in conjunction with the following setting in the hosting panel for my domain:

Use Apache instead Nginx for handling the static files like .jpg .gif .js .css .rar .exe .mp3 etc.

Yes, I have this setting in the hosting panel.

So, seems like it's final - the two things - commenting Options in the .htaccess and use Apache instead of Nginx

1

As for me, the issue with broken thumbnails was fixed in nginx config

when I added "location" directive below

location ~* \.(js|css|png|jpg|jpeg|gif|ico|svg)$
{
    try_files $uri @rewrite;
    expires max;
    log_not_found off;
}

and restarted server, it was never appeared

( using drupal 8.6.13 )

permissions of sites/default/files/styles are 777 for nginx user (owner of it)

1

This worked for me

added these lines in settings.php

$settings['file_public_path'] = 'sites/default/files';
$config['image.settings']['suppress_itok_output'] = TRUE;
$config['image.settings']['allow_insecure_derivatives'] = TRUE;

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.