# Changing image based on whether a channel is live or not

**URL:** <https://discuss.dev.twitch.com/t/changing-image-based-on-whether-a-channel-is-live-or-not/3725>\
**Category:** API\
**Created:** [October 26, 2015, 6:14am UTC](https://discuss.dev.twitch.com/t/changing-image-based-on-whether-a-channel-is-live-or-not/3725 "2015-10-26T06:14:50Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![LordofAscension](https://avatars.discourse-cdn.com/v4/letter/l/439d5e/32.png) [@LordofAscension](https://discuss.dev.twitch.com/u/LordofAscension)\
**Post date:** [October 26, 2015, 6:14am UTC](https://discuss.dev.twitch.com/t/changing-image-based-on-whether-a-channel-is-live-or-not/3725/1 "2015-10-26T06:14:50Z")

</div>

I am trying to create a simple json call coupled with an if function to display whether a channel is live or not. I am not a very good developer, but I am trying to make it work for one stream for one site. If someone could point out where my error is, that would be much appreciated. Thank you!

* * *

```
<script src="https://code.jquery.com/jquery-1.11.1.min.js"></script>
<script>
	$.getjson('https://api.twitch.tv/kraken/streams/LegacyObserver', function(channel) {

		if (channel["stream"] == "null") { 
		document.write("<img src='/grafx/offline.jpg'>");

		} else {
		document.write("<img src='/grafx/online.jpg'>");
		}
	        });
</script>
```

---

<div class="post-metadata">

**Author:** ![Fugiman](https://d3ovvz0v2ajtpu.cloudfront.net/user_avatar/discuss.dev.twitch.com/fugiman/32/108_2.png) [@Fugiman](https://discuss.dev.twitch.com/u/Fugiman)\
**Post date:** [October 26, 2015, 6:54am UTC](https://discuss.dev.twitch.com/t/changing-image-based-on-whether-a-channel-is-live-or-not/3725/2 "2015-10-26T06:54:41Z")

</div>

> **[Fugiman/Twitch-Channel-Status](https://github.com/Fugiman/Twitch-Channel-Status)**
>
> Twitch-Channel-Status - A library that makes it easy to display whether a Twitch channel is online or not

```
<script src="https://code.jquery.com/jquery-1.11.1.min.js"></script>
<script src="https://cdn.rawgit.com/Fugiman/Twitch-Channel-Status/1d74252edf89110507cbf3088f9c3eaa38fac9d3/twitch-channel-status.min.js"></script>
<img data-twitch-channel="legacyobserver" data-online-image="/grafx/online.jpg" data-offline-image="/grafx/offline.jpg">
```

---

<div class="post-metadata">

**Author:** ![system](https://d2opxh93rbxzdn.cloudfront.net/original/2X/0/05909729875cce3b53e59d5561c4d23bb14948fc.png) [@system](https://discuss.dev.twitch.com/u/system)\
**Post date:** [November 25, 2015, 6:54am UTC](https://discuss.dev.twitch.com/t/changing-image-based-on-whether-a-channel-is-live-or-not/3725/3 "2015-11-25T06:54:44Z")

</div>

Closed on November 25, 2015, 6:54am UTC

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
