Return default placeholder image when image file on server not found

What is the right way to convert this from .htaccess to nginx.conf…

##Return default placeholder image when image file on server not found
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} !-f
RewriteRule .(gif|jpe?g|png) /image404.php [NC,L]

Posted at Nginx Forum:

Found the answer on IRC #Freenode nginx by catbeard

location ~ .(png|jp?g|gif)$ {
error_page 404 /404.png;
}

Posted at Nginx Forum: