Skip to main content
Inspiring
December 15, 2022
Question

img is not showing up when add full path in src attribute

  • December 15, 2022
  • 2 replies
  • 290 views

when I add this line of code (Example 1) then the image is added and showing in the UXP UI panel but when I use the full path in the "src" attribute then it's not working.
Example 1 -
const img1 = new Image(); // Image constructor
img1.src='./ravi.jpg';
img1.alt = 'alt';
document.body.appendChild(img1)

Example 2 -
const img1 = new Image(); // Image constructor
img1.src='file://D:/Extensions/Photoshop_Ext/UXP_Extension/UxpStarterPlugin/ravi.jpg';
img1.alt = 'alt';
document.body.appendChild(img1)

This topic has been closed for replies.

2 replies

Legend
December 15, 2022

I haven't tried it, but I'd expect to see the local URL starting file:/// not just file://

Inspiring
December 16, 2022

Hi @Test Screen Name 
I'd tried "file:///" and "file://" both but not working

 

Inspiring
December 15, 2022

and it's working when I use any external link
eg;- src="https://gimage.com.au/wp-content/uploads/2017/07/G-IMAGE-logo.jpg"