# UXP REACT img tag not working

**URL:** https://forums.creativeclouddeveloper.com/t/uxp-react-img-tag-not-working/6810
**Category:** InDesign
**Tags:** uxp, javascript
**Created:** [September 12, 2023, 3:12pm UTC](https://forums.creativeclouddeveloper.com/t/uxp-react-img-tag-not-working/6810 "2023-09-12T15:12:16Z")
**Posts on this page:** 11
**Page:** 1

<div class="post-metadata">

### Author: ![Adobe256](https://avatars.discourse-cdn.com/v4/letter/a/3e96dc/32.png) [@Adobe256](https://forums.creativeclouddeveloper.com/u/Adobe256)
#### Post date: [September 12, 2023, 3:12pm UTC](https://forums.creativeclouddeveloper.com/t/uxp-react-img-tag-not-working/6810/1 "2023-09-12T15:12:17Z")

</div>

So, Am building a uxp plugin for adobe indesign. Am using react technology. Problem is, when I do import images using react import and include them using ![]() tag nothing shows. the space is blank. This is including of if I use an external link on my ![]() tag. I noticed this also on display: Grid the page was rendering blank. What could be the reason or the solution. Here is my code.

 ![react snippet 2](https://us1.discourse-cdn.com/flex015/uploads/xdplugins/original/2X/6/6f7b21e64ba4577c1d7c7bcf150d666a03457d48.png)

---

<div class="post-metadata">

### Author: ![sivar2311](https://sea1.discourse-cdn.com/flex015/user_avatar/forums.creativeclouddeveloper.com/sivar2311/32/3186_2.png) [@sivar2311](https://forums.creativeclouddeveloper.com/u/sivar2311)
#### Post date: [September 12, 2023, 5:53pm UTC](https://forums.creativeclouddeveloper.com/t/uxp-react-img-tag-not-working/6810/2 "2023-09-12T17:53:26Z")

</div>

Hi @Adobe256

You load the photo from a website.  
For this, you need to set the permission in the `manifest.json`:

```auto
  "requiredPermissions": {
    "network": {
      "domains": [
        "https://plus.unsplash.com"
      ]
    }
  },

```

I’m not on react but with the permissions set correctly the following code works:

```auto
<!DOCTYPE html>
<html>

<head>
  <script src="index.js"></script>
</head>

<body>
  <img src="https://plus.unsplash.com/premium_photo-1694473363346-31c23ae66885" width="256"/>
</body>

</html>

```

 ![image](https://us1.discourse-cdn.com/flex015/uploads/xdplugins/original/2X/f/fda06ef6b242c6c697fd2c07fc312485fded4d22.jpeg)

This also works for dynamic loading with Javascript:

```auto
...
  <img id="placeholder">
  <sp-button id="loadImage">Load image</sp-button>
...

```

```auto
document.querySelector('#loadImage').addEventListener('click', () => {
  const img = document.querySelector('#placeholder')
  img.setAttribute('src', 'https://plus.unsplash.com/premium_photo-1694473363346-31c23ae66885')
  img.setAttribute('width', '256')
})

```

---

<div class="post-metadata">

### Author: ![Adobe256](https://avatars.discourse-cdn.com/v4/letter/a/3e96dc/32.png) [@Adobe256](https://forums.creativeclouddeveloper.com/u/Adobe256)
#### Post date: [September 12, 2023, 6:22pm UTC](https://forums.creativeclouddeveloper.com/t/uxp-react-img-tag-not-working/6810/3 "2023-09-12T18:22:42Z")

</div>

how about the other part where am not loading it from a website. ? Instead am requiring it locally from my folder

---

<div class="post-metadata">

### Author: ![sivar2311](https://sea1.discourse-cdn.com/flex015/user_avatar/forums.creativeclouddeveloper.com/sivar2311/32/3186_2.png) [@sivar2311](https://forums.creativeclouddeveloper.com/u/sivar2311)
#### Post date: [September 12, 2023, 6:29pm UTC](https://forums.creativeclouddeveloper.com/t/uxp-react-img-tag-not-working/6810/4 "2023-09-12T18:29:13Z")

</div>

Using local images doesn’t require any special permissions:

 ![image](https://us1.discourse-cdn.com/flex015/uploads/xdplugins/original/2X/9/991a758910e5b7b03e99ebb4ac00cae107e77327.png)

---

<div class="post-metadata">

### Author: ![Adobe256](https://avatars.discourse-cdn.com/v4/letter/a/3e96dc/32.png) [@Adobe256](https://forums.creativeclouddeveloper.com/u/Adobe256)
#### Post date: [September 12, 2023, 6:31pm UTC](https://forums.creativeclouddeveloper.com/t/uxp-react-img-tag-not-working/6810/5 "2023-09-12T18:31:56Z")

</div>

I mean on react . js platform

---

<div class="post-metadata">

### Author: ![sivar2311](https://sea1.discourse-cdn.com/flex015/user_avatar/forums.creativeclouddeveloper.com/sivar2311/32/3186_2.png) [@sivar2311](https://forums.creativeclouddeveloper.com/u/sivar2311)
#### Post date: [September 12, 2023, 6:33pm UTC](https://forums.creativeclouddeveloper.com/t/uxp-react-img-tag-not-working/6810/6 "2023-09-12T18:33:51Z")

</div>

Afaik this should work. I don’t see any reasons why it shouldn’t.

Did you had any issues?

---

<div class="post-metadata">

### Author: ![Adobe256](https://avatars.discourse-cdn.com/v4/letter/a/3e96dc/32.png) [@Adobe256](https://forums.creativeclouddeveloper.com/u/Adobe256)
#### Post date: [September 12, 2023, 6:55pm UTC](https://forums.creativeclouddeveloper.com/t/uxp-react-img-tag-not-working/6810/7 "2023-09-12T18:55:02Z")

</div>

on the first method including an image from the network I used your link and it worked. Now, the second method on react using webpack it has not worked. So this is how the react code looks.

 ![alien pic](https://us1.discourse-cdn.com/flex015/uploads/xdplugins/original/2X/2/218f21556e4a24a5d1651204a11df99de5a3bb41.png)

Now, When I run npm run build in order to get my distro folder that contains files to be read by uxp this is what am getting.

 ![image1 issue](https://us1.discourse-cdn.com/flex015/uploads/xdplugins/original/2X/1/13f6c8746fc7a0a2179180346bec503ee48697fb.png)

On my plugin no image is loaded. the screen is blank. The name alien.jpg is replaced by that hash . I tend to think issue is on the webpack configuration but I can’t point out where. All my image loaders are correct.

---

<div class="post-metadata">

### Author: ![Karmalakas](https://sea1.discourse-cdn.com/flex015/user_avatar/forums.creativeclouddeveloper.com/karmalakas/32/1048_2.png) [@Karmalakas](https://forums.creativeclouddeveloper.com/u/Karmalakas)
#### Post date: [September 13, 2023, 8:08am UTC](https://forums.creativeclouddeveloper.com/t/uxp-react-img-tag-not-working/6810/8 "2023-09-13T08:08:41Z")

</div>

Where does this `index.js` come from at the beginning of the path?

---

<div class="post-metadata">

### Author: ![pklaschka](https://sea1.discourse-cdn.com/flex015/user_avatar/forums.creativeclouddeveloper.com/pklaschka/32/3162_2.png) [@pklaschka](https://forums.creativeclouddeveloper.com/u/pklaschka)
#### Post date: [September 13, 2023, 8:36am UTC](https://forums.creativeclouddeveloper.com/t/uxp-react-img-tag-not-working/6810/9 "2023-09-13T08:36:01Z")

</div>

That is an issue with the webpack config in Adobe’s InDesign React starter.

You need to add a `publicPath: “./“` to the `output` options for this to work. Cf. [https://github.com/pklaschka/uxp-indesign-samples/blob/main/plugins/react-swc-sample/webpack.config.js](https://github.com/pklaschka/uxp-indesign-samples/blob/main/plugins/react-swc-sample/webpack.config.js).

---

<div class="post-metadata">

### Author: ![Adobe256](https://avatars.discourse-cdn.com/v4/letter/a/3e96dc/32.png) [@Adobe256](https://forums.creativeclouddeveloper.com/u/Adobe256)
#### Post date: [September 14, 2023, 7:20am UTC](https://forums.creativeclouddeveloper.com/t/uxp-react-img-tag-not-working/6810/10 "2023-09-14T07:20:27Z")

</div>

Thankyou. It worked.

---

<div class="post-metadata">

### Author: ![Adobe256](https://avatars.discourse-cdn.com/v4/letter/a/3e96dc/32.png) [@Adobe256](https://forums.creativeclouddeveloper.com/u/Adobe256)
#### Post date: [September 14, 2023, 7:25am UTC](https://forums.creativeclouddeveloper.com/t/uxp-react-img-tag-not-working/6810/11 "2023-09-14T07:25:25Z")

</div>

When you run Webpack to build your project, it processes your source code and generates an output bundle, often named something like index.js.  
It can be any name depending on what you set on the output section.

 ![source of index](https://us1.discourse-cdn.com/flex015/uploads/xdplugins/original/2X/5/5c09bbcaa47d516ec4e27dea4c6902a1d2e286eb.png)
