How to restrict certain image file formats in Blazor RichTextEditor

Answer:

We have “AllowedTypes” property to restrict the specific file type to insert in RichTextEditor.

Index.razor

<EjsRichTextEditor Id="default_RTE">

<RichTextEditorImageSettings AllowedTypes="@allowedTypes">RichTextEditorImageSettings> // config for image file type restriction

EjsRichTextEditor>

@code{

// Specify the allowed image file types

private string[] allowedTypes = new string[] { ".png", ".jpg" };

}



2 Replies

GR Graham May 31, 2022 11:12 AM UTC

Looks like it now needs to be a List rather than an array:

private List<string> AllowedTypes = new List<string> { ".jpg", ".png", ".gif" };



BS Buvana Sathasivam Syncfusion Team June 2, 2022 04:11 AM UTC

Hi Graham,


Greetings from Syncfusion support.


Yes, we have changed the type of AllowedTypes property to a List<string> in the SfRichTextEditor component. please find the below code for your reference.


Code snippet:

 <SfRichTextEditor EnableAutoUrl="@AutoUrl">

                   

  <RichTextEditorImageSettings AllowedTypes="@allowedTypes" ></RichTextEditorImageSettings>

    </SfRichTextEditor>

@code {

    

    private bool AutoUrl = false;

   

   private List<string> allowedTypes = new List<string> { ".jpg",".png", ".gif" };  

   

}


We will change our documentation page and publish it in any one of our upcoming releases.

Regards,

Buvana S


Loader.
Up arrow icon