Prototype

property OnImageValidate: TImageValidateEvent read FOnImageValidate write FOnImageValidate;

Description

Occurs when loading the document or when switching between light and dark modes, using SelectMode, for each image, if they contain parameters.

Set aAccept to true to accept the image or to false to reject it. A rejected image is not rendered.


Note: if the control is associated with a TMDStyle that also handles this event, both must return true in aAccept.

Example

This Markdown script contains two images: one for light and one for dark mode.

![img](BlackImage.jpg#light)
![img](WhiteImage.jpg#dark)

In your application, handle the OnImageValidate event as follow:

procedure TForm1.MDViwer1ImageValidate(Sender: TObject; const aName: string; aParams: array of string; var aAccept: Boolean);
begin
  aAccept := ((MDStyle1.Mode = smLight) and not MatchText('dark', aParams)) or
             ((MDStyle1.Mode = smDark) and not MatchText('light', aParams));
end;

See also

TMDStyle.Mode

TMDStyle.SelectMode

TMDViewer.LoadFromURI