Depends on how you're receiving/passing the image, just set it to a variable and check for it.
This is the easy/lazy solution to this simple problem, if your problem is more complex you could turn this into a function that checks and replaces sunny, stormy, etc...
if (img === "http://www.google.com//ig/images/weather/sunny.gif") {
img = "myownimage.gif";
}
PHP/JS anti-pattern:
<?php if ($image === "http://www.google.com//ig/images/weather/sunny.gif"): ?>
<script type="text/javascript">
$("#image").attr('src', 'foo.gif');
</script>
<?php endif; ?>
But honestly if you're receiving the image in PHP, then I'd just manipulate it server-side and display it to the client then rather than have JavaScript do it...
<?php
if ($image === "http://www.google.com//ig/images/weather/sunny.gif") {
$image = 'foo.gif';
}
?>
<img src="<?php echo $image ?>" alt="my sunny day image" />