This is globally controlled by apache, or locally controlled by your .htaccess file (which basically changes the local apache configurations on local folders).
Just add the following code to your .haccess file and adjust as per your requirements
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_URI} \.(gif|jpg|jpeg|png)$
RewriteRule .* /var/www/html/malla-supply/img/p/en.jpg [L]
To do it Programatically in prestashop
Just add the code to Tools.php around line 2374
fwrite($write_fd, "RewriteBase /\n");
fwrite($write_fd, "RewriteCond %{REQUEST_FILENAME} !-f\n");
fwrite($write_fd, "RewriteCond %{REQUEST_URI} \.(gif|jpg|jpeg|png)$\n");
fwrite($write_fd, "RewriteRule .* /var/www/html/malla-supply/img/p/en.jpg [L] \n");