TWebImageSlider load from MySQL database via PHP


I need a bit of help. The php call here loads correctly in a browser but when I add it to the ImageURLs of the slider it doesn't display anything.

This is probably because the PHP to return the JPEG image is:

echo '<img src="data:image/jpeg;base64,'.base64_encode($img).'"/>';

What do I need to return to get this to work in the slider?

I have tried echo $img and echo base64_encode($img).



The TWebImageSlider works with an image URL list set via WebImageSlider.ImageURLs: TStringList.
This is a list of URLs.
When your PHP code returns image HTML tags (<IMG>) this is NOT an image URL and will as such not work. You could try to return something like

data:image/jpeg;base64 + base64_encode($img)

(Note that I have no PHP expertise)

Thanks Bruno. Unfortunately I can't get that, or any combination of it, to work.

You can see in the TWebImageSlider demo that the images are just a string list of URLs.
If you fill this string list and then call WebImageSlider.Update, this should do it.

I was using a modified version of your demo. Update is protected. The demo calls RefreshImages.

Did you try to call RefreshImages?

Other than this, if something fails, please report errors, provide details so we are able to understand what is happening.

Yes I did. It is not a problem as such with the control. Just my ability to be able to deliver them in the correct format from a blob in the database. I could obviously save them to a file (which I have done as a test) but that would be a complete duplication of the data.

For info I worked out how to do this which is shown below. One problem with the image slider is that you have to provide large images which can take a while if there are lots of them. It would be much better if you could provide small images for the thumbnails and have an event to be able to populate the large image.

     procedure(AResponse: string; ARequest: TJSXMLHttpRequest)
       for I:=0 to jsArr.Count-1 do
         jsO:=jsArr.Items[I] as TJSONObject;