I have a fresh composer install of drupal 8 on Freebsd. When I try to upload any jpg/gif/png file to media browser file is uploaded correctly, but thumbnail is not generated.
I can observe the uploaded file in the list of media files but thumbnail is broken.
The uploaded file may be opened correctly and have URL like /sites/default/files/2020-03/filename-11_6.jpg.
The URL of thumbnail is like /sites/default/files/styles/thumbnail/public/2020-03/filename-11_6.jpg?itok=ducg-SU7.
The /sites/default/files/styles/ folder is empty. It have permission 777.
I have try to create appropriate folders structure inside the /sites/default/files/styles folder but thumbnails are still not generated. Manually created folders are removed when I flush at the /admin/config/media/image-styles
How can I force Media to work properly?
WORKAROUND / RESOLUTION:
for Nginx systems:
https://www.drupal.org/project/drupal/issues/3120676#comment-13764129
remove nginx directive
# Set images and js to expire in a very long time
location ~* \.(ico|css|pdf|jpg|jpeg|png|gif|js|xml|js|woff|woff2|ttf|svg|eot)$ {
expires 7d;
}
then all thumbnails under sites/default/files/styles/ should be generated and visible.
Remaining tasks
Investigate if feasible to create a patch for hook requirements implementation that would validate a correctly configured Nginx server configuration for styles, this would provide help text if the configuration is determined to be incorrect.
Apache2 doesn't seem to have this problem but perhaps a similar configuration in Apache2 might cause issues, the same hook requirements validation might be best to validate image style creation and file_exists in a generic way for any server type
if feasible, create patch
Issue fork drupal-3120676
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #2
joseph.olstadRather than use the media module (contrib project) you should be using the core media module (the one provided by core)
from this contrib module page:
Comment #3
joseph.olstadComment #4
joseph.olstadkeeping in mind, this functionality should now work ' out of the box' with drupal core 8.8.x +
So a core module (inclued with core) called media (same name) is included in Drupal 8 core version 8.4+ , and starting with 8.8+ theres advanced out of the box media functionality.
Comment #5
a_sh commentedYes, I am using Media included into drupal installation
CORE
Manages the creation, configuration, and display of media items.
Machine name: media
Version: 8.8.4
Requires: FileFieldImageUserSystem
Comment #6
joseph.olstadAssigning issue to the correct queue. This is a CORE issue not a contrib module.
Comment #7
joseph.olstadComment #8
a_sh commentedHow can I track Drupal file operations?
I want to force drupal to log all file operations (especially file creation). Is it possible?
Comment #9
a_sh commentedIt seems that issue is caused by some broken dependence....How can I check them?
Comment #10
joseph.olstadinspect the element containing the link to the thumbnail, the styles path hints towards which image style (machine name) is being used. You can test the image style by providing a path to an image in the pattern that is found. Check your image styles, perhaps your server has insufficient write permissions to the sites/default/files/styles folder?
otherwise, check to see if that machine name image style exists, if not, create it.
does your server have sufficient write permissions to be able to write to the sites/default/files/styles folder?
or sites/{sitename}/files/styles folder if it is not default.
Comment #11
a_sh commentedThe url of thumbnail is /sites/default/files/styles/thumbnail/public/2020-04/filename.jpg?itok=KBbfScLy
with class="image-style-thumbnail"
The corresponding image style exist, however corresponding folders are not created. I did try to add custom image style - the situation is the same.
I did try to create the appropriate folders structure inside the /sites/default/files/styles folder but thumbnails are still not generated. Manually created folders are removed when I flush at the /admin/config/media/image-styles
Imagick or GD - doesn't matter.
This problem shouldn't be related to permissions - styles is 777.
Problem is reproduced on two systems with Freebsd 12.1 and 10.4 (both nginx/php-fpm)
Comment #12
joseph.olstadcheck the thumbnail image style in /admin/config/media/image-styles
alternatively, delete it, and then recreate it with the same settings.
see if this helps.
Comment #13
joseph.olstadif you use imagick make sure you have the imagick dependencies installed on your server. check your reports log
Comment #14
a_sh commentedYes, I did try to create a new image style and assign them to thumbnail. Not working.
Both imagick and GD show the same behavior - no thumbnails at all. \
There are no any strange errors in the log.
Comment #15
joseph.olstadis your 'files' folder symlinked outside of somewhere?
or your styles folder, is it a symlink to somewhere?
are there other 'styles' that work? or is it just the thumbnails styles?
have you tried disabling the image module? and re-installing it?
have you done a config export and config import? is there config information that is causing a bad setting?
have you done a drush updb -y or visitted update.php when logged in? making sure you get schema updates?
what version of php are you using?
if you are using Linux, have you disabled selinux and disabled apparmor?
try disabling apparmor and make sure selinux is disabled, these two things can do weird things to your permissions and restrict things to the point that they stop working unless you really know how to use apparmor and selinux they should be disabled .
check with your operating system vendor for more details.
Comment #17
DerekRoth commentedHi,
I have the exact same issue:
I'd like to dig into the code to see what is wrong and for this i need more information:
I'm running PHP 7.2, Drupal 8.7.13, GD2, Apache and the core Drupal module for media.
Comment #18
a_sh commentedHi, DerekRoth
What OS are you running?
Comment #19
Haessler commentedI had the same issue: No thumbnails generated on a new install (D 8.9 PHP 7.4, Centos), styles folder remained empty. I removed a nginx directive
# Set images and js to expire in a very long time
location ~* \.(ico|css|pdf|jpg|jpeg|png|gif|js|xml|js|woff|woff2|ttf|svg|eot)$ {
expires 7d;
}
and all thumbnails under styles where generated and visible.
Ulli
Comment #20
athrylith commentedWe have had a similar problem with a custom Warpwire OEmbed provider we've created. The problem seems to be in how the thumbnail url is being formed. Warpwire does not include an extension on thumbnails which causes line 396 in Drupal\media\Plugin\media\Source (D9.0.2)
$local_thumbnail_uri = "$directory/" . Crypt::hashBase64($remote_thumbnail_url) . '.' . pathinfo($remote_thumbnail_url, PATHINFO_EXTENSION);
to create a filename ending in '.', which is illegal, so no thumbnail is being created. We are currently testing a solution that uses GD2's getImageSize() to read the correct image type and append the correct extension.
Comment #21
phenaproximaIt would be really helpful to get steps to reproduce in the issue summary here, starting from a clean installation of Drupal core.
Comment #22
phenaproximaComment #23
a_sh commentedIt works! Thank you very much!
Comment #24
joseph.olstadseeing as this is an nginx specific issue, is there anything we can do from the application side to mitigate this?
perhaps add a hook_requirements check for nginx that tests for this bad configuration?
Comment #25
joseph.olstadComment #26
joseph.olstadComment #27
joseph.olstadComment #28
joseph.olstadComment #29
stuiegreen commentedWorked for me. YEEESSSSSS!!!
Comment #30
gurunathan commentedThe solution #19 says to remove the nginx directive.
How to do it?
Comment #32
tunprogI had the same issue with image styles on Drupal 9 version 9.2.10. Fixed it by removing these lines from my nginx configuration file:
Comment #34
marvs5 commentedThis is still an issue. I am running a D9 site on Nginx and it wasn't making the thumbnails until I removed the above Nginx location directive. Clearly this is still suboptimal.
Comment #36
arturopanettaSame problem for me too. Removing the NGINX rule makes the thumbnails visible again.
Drupal:9.3 (docker image)
NGINX:1.20 (docker image)
Comment #38
jukka792 commentedI have same issue with D9.3.16
Image styles appears only after cron run. Nonen of the above mentioned nginx conf removals helped.
This is weird, it used to work and works in production but when site copied to local does not work. tried woth php 7.4 and 8.1
Comment #39
khurrami commented#32 Worked for Thanks a lot.
Comment #40
brianwagner commentedI'm also seeing this issue with Drupal 9.4.5 on Debian, running Nginx 1.18.0. I modified the recommended Nginx Drupal config as mentioned above. No change.
The styles/ directory is not created at all. No error messages in Drupal, Nginx, or PHP-fpm. It's unclear where else to look for debugging info.
Comment #41
Youcanlearnit commentedI have same issue.
Folders are not created in styles folder, and thumbnail images are not created.
PHP 8.1.8
NGINX 1.18
Drupal 9.4.5
None of the fix to NGINX configurations helps.
Tried to change styles folder permissions but no help.
I have another production server with same site and server packages, and it does not have this issue.
Also my local environment has this issue. I have tried all possible things, but nothing looks to help.
Comment #42
vishnutrz commentedHello @youcanlearnit
you can try this NGINX config file - https://www.nginx.com/resources/wiki/start/topics/recipes/drupal its works for us when face the same issue.
the link taken from https://www.drupal.org/project/drupal/issues/3285320 comment #7
Comment #44
rowbotony commented[~~~ Updated Comment #2 (Nov. 5, 2023) ~~~~]
Here's what the AI overlords have to say about, this fixed my specific problem on my local DDEV instance. I hope it helps others.
https://chat.openai.com/share/80e83546-b512-4a07-af75-789afe7be6a1
[~~~ Original Comment #1 (Oct. 28, 2023) ~~~~]
Update with my own experience. I'm using DDEV with Acquia Migrate Accelerate to move a D7 site to D9. All of my images were broken and wouldn't display. The original images were there, media uploads worked fine, file system permissions were correct, PHP, GD, etc were good.
The DDEV
seconddocroot.conf.examplehas the following line, when removed, thenddev restart, it worked - my images were back, and now the styles were being properly generated!If you are running Nginx, and you have image generation problems, this is still relevant.
Comment #45
poker10 commentedI am not sure where this directive come from:
In all examples/recommended configs for Nginx I see that there is an additional line:
See:
As far as I know, these configs are working without need to remove the whole directive used for caching static content.
The Issue summary should at least include the full nginx config used on sites experiencing this and clear steps to reproduce. Thanks!
Core currently does not supply an example nginx config unless this is in #2937161: Provide documentation/default server block for Nginx server., so I think that this seems like more a Support request (not sure anything can be done here until that issue is committed and there is an estabilished default config supported by core). So I think we can either make this a Support request, or postpone it.
Comment #48
quietone commentedI skimmed through the comments and all the reports are for currently unsupported versions of Drupal. Two years ago, in #45, @poker10 gave a solution. Therefor I am closing this support request.
The Drupal Core issue queue is not the ideal place for support requests. There are several support options listed on our Support page, including the Drupal Forums and Drupal Answers.