After an update to Magento 2, we encountered a problem where images in the WYSIWYG editor were no longer displayed. However, when we uploaded a new image, it was displayed without any issues. All other files located in the WYSIWYG folder were still not displayed. Since the file permissions were correct and the error messages did not provide any specific clues about the problem, we had to investigate further.
Analysis of the problem
Our next step was to check the database. We specifically searched for the test image that we had previously uploaded and that was displayed correctly in the editor. We discovered that there was indeed a database entry for this newly uploaded image. To our surprise, however, it was the only entry in the relevant table – all other images that had previously been located in the WYSIWYG folder no longer had any entries.
Solution: Synchronizing media content
After some research, we discovered that the problem could be resolved with a simple SSH command in the console. The following command restored the missing database entries:
bin/magento media-content:sync
Running this command automatically restored the missing database entries. The WYSIWYG editor was once again able to access all existing files in the folder, and the images were displayed correctly.
Conclusion
If images are no longer displayed in the WYSIWYG editor after a Magento 2 update, even though the file permissions are correct, this may be due to missing database entries. The media-content:sync command can quickly and easily restore these entries, allowing the editor to display all images again.
