# Change Image Path Pending a Tag Value Change

**URL:** <https://forum.inductiveautomation.com/t/change-image-path-pending-a-tag-value-change/11626>\
**Category:** General Discussion\
**Created:** [May 5, 2016, 6:21pm UTC](https://forum.inductiveautomation.com/t/change-image-path-pending-a-tag-value-change/11626 "2016-05-05T18:21:26Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![John\_S](https://avatars.discourse-cdn.com/v4/letter/j/a9a28c/32.png) [@John\_S](https://forum.inductiveautomation.com/u/John_S)\
**Post date:** [May 5, 2016, 6:21pm UTC](https://forum.inductiveautomation.com/t/change-image-path-pending-a-tag-value-change/11626/1 "2016-05-05T18:21:26Z")

</div>

Hello,

I am trying to make an image change when a tag value has changed within a component script. Below is the code I have so far based on how I would expect it to work. Can anyone tell me what I am doing wrong or if a component script is not the best way to do this?

if “ZTrak/Station 14/Station 14 Bundle Number” == “BM25120”:  
system.nav.swapTo(“CEgx26338.png”)  
elif “ZTrak/Station 14/Station 14 Bundle Number” == “BM25107”:  
system.nav.swapTo(“CEgx26336.png”)  
elif “ZTrak/Station 14/Station 14 Bundle Number” == “BM25112”:  
system.nav.swapTo(“CEgx26337.png”)  
else:  
system.nav.swapTo(“ztrak.png”)

Thank you!

---

<div class="post-metadata">

**Author:** ![John\_S](https://avatars.discourse-cdn.com/v4/letter/j/a9a28c/32.png) [@John\_S](https://forum.inductiveautomation.com/u/John_S)\
**Post date:** [May 9, 2016, 4:54pm UTC](https://forum.inductiveautomation.com/t/change-image-path-pending-a-tag-value-change/11626/2 "2016-05-09T16:54:59Z")

</div>

TTT…

---

<div class="post-metadata">

**Author:** ![JordanCClark](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/jordancclark/32/83362_2.png) [@JordanCClark](https://forum.inductiveautomation.com/u/JordanCClark)\
**Post date:** [May 9, 2016, 5:29pm UTC](https://forum.inductiveautomation.com/t/change-image-path-pending-a-tag-value-change/11626/3 "2016-05-09T17:29:08Z")

</div>

Hi John,

Where exactly are you putting this script? At first blush (and not enough info), I’d say you’re trying to bind to property, which will require an expression, and not a script.

If so, you may want to look at the switch function. The attached window shows an example of this in the Image Path property of the image component.  
[attachment=0]Image Pointer\_2016-05-09\_1326.proj[/attachment]

As the script itself is concerned, system.nav.swap() navigates between windows and not really suitable for images.

Or maybe I’m all wet, and I don’t really know what you’re looking to do. Age, and all that… 😆

Let me know what I can do to help.

---

<div class="post-metadata">

**Author:** ![rrdiggy76](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/rrdiggy76/32/3741_2.png) [@rrdiggy76](https://forum.inductiveautomation.com/u/rrdiggy76)\
**Post date:** [May 10, 2016, 9:54pm UTC](https://forum.inductiveautomation.com/t/change-image-path-pending-a-tag-value-change/11626/4 "2016-05-10T21:54:55Z")

</div>

I replace images with those i have uploaded to the Image Management component using the ‘replace’ expression function.

When the tag changes, i take the value of the tag, substitute into the image path using the replace expression and fetch an image from that folder.

All my images have the same name (such as ‘header’, even though they differ), but the folder path changes.

The only caveat is that your folder structure needs to match the tag names otherwise the look up will not work…
