开发者

404 Image Placeholder

开发者 https://www.devze.com 2023-04-13 02:07 出处:网络
I\'ve got a product gallery I\'m working on and just did an开发者_如何学JAVA import.This added a bunch of references to images that don\'t exist on the server.

I've got a product gallery I'm working on and just did an开发者_如何学JAVA import. This added a bunch of references to images that don't exist on the server.

Right now when the image tries to load, it's got that broken image icon, which is ugly, and well, should be handled better.

Ideally, whenever a broken image would be displayed -- that is to say when an image's path just doesn't exist -- I would like Apache to show a placeholder image instead.

Is there any way to do this via .htaccess?


Use RewriteCond with -f to check if the file exists, e.g.:

RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^.*(\.gif|\.jpe?g|\.png)$ placeholder.jpg [L]
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号