Home > Enterprise >  Prevent rendering image inside input field
Prevent rendering image inside input field

Time:07-15

I have normal text input like this

<input type="text" id="pixel_url_<?php echo $link_id;?>" value="<?php echo $pixel_url;?>"  placeholder="Link URL">

I am looking to display img code inside input value so my users can see it and copy it. like below image

enter image description here

But my code is showing output like below image

enter image description here

my value is like below

<img src="https://example.com/pixel/action?link=25&att=2&ref=" width="1" height="1">

I am not getting idea how I can prevent image rendering and show it in input value.

Thanks!

CodePudding user response:

The reason it is not working is that the quotes besides the value attribute are double quotes, also the quotes in your img element are double. You either need to escape the quotes of the img element or alternate the quotes of the value attribute or img element.

Try this:

value='<?php echo $pixel_url;?>'
  • Related