rtrim replaced to preg_replace cuz we need to replace whole word (.png, .jpg or .gif). Not just characters

Signed-off-by: Jan Linhart <jan.linhart@easysoftware.cz>