TWebImageControl image

Hi!


Is possible to detect if TWebImage has a picture or "is empty"? I would like to hide it if there is no image.

Check if URL is empty string?

Hmm.. yes, but I open a detail form and load everythin through XData, after loading I load also the picture with this code




procedure TfrmDetails.OnServerConnect(Sender: TObject);
begin
  wdsPobuda.QueryString := '$filter=Id eq '''+IntToStr(Id)+'''&$expand=status';
  wdsPobuda.Load;
end;


...


procedure TfrmDetails.wdsPobudaAfterOpen(DataSet: TDataSet);
begin
  imgSlika.Url := connServer.URL + '/pobuda('+wdsPobuda.FieldByName('Id').AsString+')/Picture';
end;


On the next step I'm checking if anything has loaded - if yes then I show the image.

Maybe I'm just doing all wrong, but I don't know how to load the picture only if it is present in the DB, so I'm checkon after the load.

Do I understand correct that the URL can be an invalid link and you want to detect that?

If you want to check if the URL exists, you could use a HTTP request and check the response code.

Ok, I'll go this way


In Delphi code, I 'm trying to do this


imgPicture.Visible := imgPicture.Picture <> nil;


But is always true.. :)

I'm trying to understand if the saved entity has a picture or not (picture is optional for the users). if there is no picture then on the page is displayed an ugly square and I want to hide it if there is no picture in the DB. I tried with 


imgPicture.Visible := imgPicture.Picture <> nil;

but gives always true.
uses
  WEBLib.WebTools;

Set WebImageControl.URL := EmptyImage;

if you do not want to see the default browser displaying it could not find an image.

Ok, but how do I check that the WebImageControl has no picture in it? I set the URL



  imgSlika.Url := connServer.URL + '/pobuda('+wdsPobuda.FieldByName('Id').AsString+')/Slika';


If there is a picture, it is displayed, but if there is no picture then I get the ugly square (that I now know how to hide thanks yo your post). But how to check if the picture is in the DB (XData server) or the DB has no picture?

I understand that basically you want to check if an URL is valid?

If so, you can use the component TWebURLValidator for this.
Set the URL of the image and it will respond via the event OnValidated if the URL is valid or not.

I'll try this.


Basically I want to check if the picture is present or if the TWebImabeZom component is empty (no picture). In "classic" delphi it was just matter of checkin if picture = nil, but in Web Core doesn't work. There is no property to check if a pictue has been loaded or the TWebImabeZom is empty.

TWebURLValidator works for the task. Take the previous post as a suggestion for future updates.

There is no property in the TWebImageZoom component as the browser DOM doesn't offer this out of the box on the HTML IMG element.