Loading Images from JSon (External URL)

Stimulsoft Reports.JS discussion
Post Reply
dev3creatives
Posts: 5
Joined: Mon Apr 23, 2018 2:45 pm

Loading Images from JSon (External URL)

Post by dev3creatives »

Hello Everyone!!!,

I have a json with a data structure, this structure is my data dictionary and I have a series of information there, including the url of the images that I need to show in the report.

My question is...

How can I insert these images from the url?

Example:

Code: Select all

"registry": [{ 
     "room1": "http://server.com/1.jpg",
     "room2": "http://server.com/2.jpg",
     "kitchen": "http://server.com/3.jpg",
     "bathroom": "https://server.com/4.jpg"
}]
And I need to insert the images on a page where I have 4 image tags. This information is variable and I need that every time the JSon changes the images change

Thanks in advance
HighAley
Posts: 8431
Joined: Wed Jun 08, 2011 7:40 am
Location: Stimulsoft Office

Re: Loading Images from JSon (External URL)

Post by HighAley »

Hello.

If you need to load an image form an external URL.
You should use CORS.

Thank you.
dev3creatives
Posts: 5
Joined: Mon Apr 23, 2018 2:45 pm

Re: Loading Images from JSon (External URL)

Post by dev3creatives »

Hello,

Yes, i need to load an image from a JSon, how i was explain.

Asign a URL stored on JSon Column to an image...

Are you follow me?

Can you help me?
HighAley
Posts: 8431
Joined: Wed Jun 08, 2011 7:40 am
Location: Stimulsoft Office

Re: Loading Images from JSon (External URL)

Post by HighAley »

Hello.

You sent us JSON with URLs of the images.
Could you specify your scenario more detailed?
Do you store images or URLs in your JSON data?

Thank you.
dev3creatives
Posts: 5
Joined: Mon Apr 23, 2018 2:45 pm

Re: Loading Images from JSon (External URL)

Post by dev3creatives »

Ok, its my problem..

I need insert an image in the report but the URL come from my JSon data source (Dictionary)
and that image cant display dynamically from the data source, the only way that i can display one image is by hypervincule manually..

I want to set a Column Data from JSon like a Source of those images

Example JSon

Code: Select all

[{
   "id":"001",
   "first_name":"Jhon",
   "last_name":"McDonald",
   "pictures": [{ 
         "room1": "http://server.com/1.jpg",
         "room2": "http://server.com/2.jpg",
         "kitchen": "http://server.com/3.jpg",
         "bathroom": "http://server.com/4.jpg"
    }]
}]
Thanks in advance
HighAley
Posts: 8431
Joined: Wed Jun 08, 2011 7:40 am
Location: Stimulsoft Office

Re: Loading Images from JSon (External URL)

Post by HighAley »

Hello.

If you need to show several images dynamically and their quantity is variable you could make some changes in your JSON:

Code: Select all

[{
		"id": "001",
		"first_name": "Jhon",
		"last_name": "McDonald",
		"pictures": [{
				"name": "room1",
				"url": "http://server.com/1.jpg"
			}, {
				"name": "room2",
				"url": "http://server.com/2.jpg"
			}, {
				"name": "kitchen",
				"url": "http://server.com/3.jpg"
			}, {
				"name": "bathroom",
				"url": "http://server.com/4.jpg"
			}
		]
	}
]
Please, look at the attached report template.

Thank you.
Attachments
Report (19).mrt
(3.86 KiB) Downloaded 379 times
dev3creatives
Posts: 5
Joined: Mon Apr 23, 2018 2:45 pm

Re: Loading Images from JSon (External URL)

Post by dev3creatives »

Thank you, that works fine!!
Andrew
Posts: 4106
Joined: Fri Jun 09, 2006 3:58 am

Re: Loading Images from JSon (External URL)

Post by Andrew »

Hello,

You are welcome!
Post Reply