<html>
<head>
<style>
</style>
</head>
<body>
<div class="container">
	<img src="1.gif" alt="">
	<img src="1.png" alt="">
	<img src="2.gif" alt="">
	<img src="2.png" alt="">
</div>
	<script>
[].forEach.call(document.querySelectorAll('.container img[src$=".gif"]'), function (el){
 el.src = 'http://forumavatars.ru/img/avatars/0014/21/71/4-1403302678.png';
});
	</script>
</body>
</html>
можно проще