No answer on my question
How to get image in a sharepoint page using rest api jquery?
I have an announcement list that contains title, body and image column for each item. And I have a page that should return the last item (title,body and image) from announcement list. Now I have the rest API jquery that is ready to get the body and the title. But I don't know how to return the image of the item itself in the code.
Can anyone help me?
31975-anno.txt
3 answers
Sort by: Most helpful
-
-
MichaelHan-MSFT 18,031 Reputation points
2020-10-14T04:28:30.043+00:00 Hi @Gulnar ,
What's the type of your image column? Is it Hyperlink or Picture?
If so, you could try to use this:
$("#image").html("<img src='" + data.d.results[0].Image.Url +"'>");
If an Answer is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread. -
MichaelHan-MSFT 18,031 Reputation points
2020-10-14T06:26:03.413+00:00 Hi @Gulnar ,
Per my test, when I use Image column in the list. I get this value for the image column in the rest api :
We need to get the serverRelativeUrl from the string. You could use the below code to get this;
var image=data.d.results[0].Image.match('"serverRelativeUrl":(.*),"id"'); $("#image").html("<img src="+ image[1] + ">");