TWebImageSlider load from MySQL database via PHP

Hi,

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).

Thanks,

Ken

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.

  HttpReq.URL:=myURL;
  HttpReq.Execute(
     procedure(AResponse: string; ARequest: TJSXMLHttpRequest)
     begin
       js:=TJSON.Create;
       jsArr:=TJSONArray(js.Parse(AResponse));
       for I:=0 to jsArr.Count-1 do
       begin
         jsO:=jsArr.Items[I] as TJSONObject;
         ImageSlider.ImageURLs.Add('data:image/jpeg;base64,'+jsO.GetValue('Image').Value);
       end;
       js.Free;
       ImageSlider.RefreshImages;
       EnableProperButtons;
     end
  );