# Using a variable to set image each repeat

**URL:** <https://discourse.psychopy.org/t/using-a-variable-to-set-image-each-repeat/14213>\
**Category:** Online experiments\
**Created:** [June 12, 2020, 3:55pm UTC](https://discourse.psychopy.org/t/using-a-variable-to-set-image-each-repeat/14213 "2020-06-12T15:55:34Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![andrewildman](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/andrewildman/32/8707_2.png) [@andrewildman](https://discourse.psychopy.org/u/andrewildman)\
**Post date:** [June 12, 2020, 3:55pm UTC](https://discourse.psychopy.org/t/using-a-variable-to-set-image-each-repeat/14213/1 "2020-06-12T15:55:34Z")

</div>

I’m getting the following error when trying to test my paradigm online

- when setting the image of ImageStim: response\_image
- when getting the value of resource: stimuli/B1\_30.png
- **unknown resource**

stimuli/B1\_30.png is from the variable current\_image, created with the following line of code:

```auto
current_image = 'stimuli/B1_' + str(currentPos) + '.png'

```

The image component then has $current\_image, set every repeat

Putting the same path directly into an image component finds the image with no problem

---

<div class="post-metadata">

**Author:** ![wakecarter](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/wakecarter/32/5753_2.png) [@wakecarter](https://discourse.psychopy.org/u/wakecarter)\
**Post date:** [June 12, 2020, 4:03pm UTC](https://discourse.psychopy.org/t/using-a-variable-to-set-image-each-repeat/14213/2 "2020-06-12T16:03:15Z")

</div>

Copy your images to html/resources/stimuli locally and resync

---

<div class="post-metadata">

**Author:** ![andrewildman](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/andrewildman/32/8707_2.png) [@andrewildman](https://discourse.psychopy.org/u/andrewildman)\
**Post date:** [June 12, 2020, 6:37pm UTC](https://discourse.psychopy.org/t/using-a-variable-to-set-image-each-repeat/14213/3 "2020-06-12T18:37:03Z")

</div>

Brilliant, that’s working now. Thank you!

---

<div class="post-metadata">

**Author:** ![wakecarter](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/wakecarter/32/5753_2.png) [@wakecarter](https://discourse.psychopy.org/u/wakecarter)\
**Post date:** [June 13, 2020, 6:44am UTC](https://discourse.psychopy.org/t/using-a-variable-to-set-image-each-repeat/14213/4 "2020-06-13T06:44:38Z")

</div>

Cool. Please could you mark my reply as the solution?

---

<div class="post-metadata">

**Author:** ![jhilik](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/jhilik/32/13089_2.png) [@jhilik](https://discourse.psychopy.org/u/jhilik)\
**Post date:** [September 6, 2020, 6:39pm UTC](https://discourse.psychopy.org/t/using-a-variable-to-set-image-each-repeat/14213/5 "2020-09-06T18:39:07Z")

</div>

I am accounting the same error.

Unfortunately we encountered the following error:

- when setting the image of ImageStim: image
- when getting the value of resource: grp1Letter\adlam\_10.png
- **unknown resource**

Try to run the experiment again. If the error persists, contact the experiment designer.

PS: I have copied the images locally in html\resources\grp1Letter locally, and re-synced. Still the error persists

---

<div class="post-metadata">

**Author:** ![jhilik](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/jhilik/32/13089_2.png) [@jhilik](https://discourse.psychopy.org/u/jhilik)\
**Post date:** [September 7, 2020, 3:17am UTC](https://discourse.psychopy.org/t/using-a-variable-to-set-image-each-repeat/14213/6 "2020-09-07T03:17:21Z")

</div>

Using forward slash “/”, instead of backslash “” solved the problem.
