Issue Encountered

I came across this issue when I was adding a media item on a client site, for some reason all the “document” media item have lost its thumbnail; After inspecting via the “Network” panel in the developer tools, it is found that the media-icons genereated by the GD2 Toolkit at url /sites/default/files/styles/thumbnail/public/media-icons/generic/generic.png?itok=xxyyzz have gotten a 404 not found error with respond body being Error generating image, missing source file .

Under the “Claro” admin theme, there is a particular issue where, if the thumbnail is missing, the text label for the document becomes obscured. It gets tucked under a white box, making it unreadable.

2025-03-25T144913

Issue Resolved

After some research, it is found that the GD2 Image Toolkit (in Drupal) infact doesn’t generate image from file, instead it chooses one of the image “template/default” based on the type of the file. For intance, if the file is an audio file, it will choose ``/sites/default/files/styles/thumbnail/public/media-icons/generic/audio.pngas the thumbnail ; if the file is anpdf/docx/csvfile, it will choose/sites/default/files/styles/thumbnail/public/media-icons/generic/generic.png` as the thumbnail.

The issue is simply those files are not existing on the path, though it still remains a mystery for me when I wrote this post, that why drupal dones’t have those fiels by default, or use the ones located inside the /core/modules/media/images/icons/audio.png instead….

The path is pretty easly, simply create the styles directory under the sites/default/files directory (along with all the required sub-directories and thumbnail files), I’ve included an example style.zip file you can extract in the sites/default/files directory: 【styles.zip

2025-03-25T150523

2025-03-25T151013