Hola, kech.
Modificando un poco el código que has puesto quedaría así:
Código PHP:
<html>
<head>
<script language="JavaScript">
function ponerImagen() {
var nWdt = screen.width;
if (nWdt >= 1024)
document.write('<img src="imagen1.gif">');
else
document.write('<img src="imagen2.gif">');
}
</script>
</head>
<body>
Aquí va mi imágen:<br>
<script>ponerImagen()</script>
</body>
</html>
Espero que te sirva. Saludos,