问题:
部署files.gallery后发现预览图片时并不能正常显示图片或全部只显示图标图标需要点击图片才能正常浏览。
解决办法:
1、检查Files Gallery的_files/config/config.php,打开以下选项
'load_images' => true, // 确保启用了图像加载
'image_resize_enabled' => true, // 启用缩略图生成
'image_resize_cache' => true, // 启用缩略图缓存
'image_resize_dimensions' => 320, // 缩略图尺寸
'image_resize_quality' => 85, // 压缩质量
'image_resize_memory_limit' => 256, // PHP 处理图像的内存限制
'image_resize_max_pixels' => 60000000, // 调整大小时允许的最大像素
'image_resize_types' => 'jpeg, png, gif, webp, bmp, avif', // 允许生成缩略图的图片类型
2、检查是否安装并启用gd库(这个项目需要GD库进行图像处理)
php -m | grep gd
没有返回gd则需要进行安装
sudo apt install php-gd
重启apache
sudo systemctl restart apache2
3、确保上传目录是否拥有写入权限(可选,若之前设置上传并上调上传大小限制时已经设置则可以跳过)
sudo chmod -R 775 /网站根目录
4、手动清除缩略图缓存
rm -rf _files/cache/images/*
刷新网页,查看项目是否正常显示,若显示则结束。
5、检查是否启用了ImageMagick(可选)(若上部已经成功可不管)
若Files Gallery依赖ImageMagick,需要确保它正确安装
sudo apt install imagemagick
检查配置
'imagemagick_path' => 'magick',