How to convert the drupal-entity tag into an img tag? I have a content type with a text field that uses CKEditor, in the editor is possible to add a media entity image, once the image is inserted inside the text the html tag for it is:

&lt;p&gt;Document&lt;/p&gt;\r\n\r\n&lt;drupal-entity alt=\"Luz\" data-embed-button=\"media_browser\" data-entity-embed-display=\"media_image\" data-entity-embed-display-settings=\"{&amp;quot;image_style&amp;quot;:&amp;quot;&amp;quot;,&amp;quot;image_link&amp;quot;:&amp;quot;&amp;quot;}\" data-entity-type=\"media\" data-entity-uuid=\"4076130e-9ccb-43f1-a4d9-dc8176271ffa\" title=\"Luz\"&gt;&lt;/drupal-entity&gt;\r\n


I have in the site a webservice that need to provide the text field with all the information, but I need to convert the drupal-entity tag into an img tag to provide a tag that can be used from the applications that use the webservice.

I made a search inside the CKEditor configurations and in the media module but I can't find any related to this, how can I convert the drupal-entity tag into an img tag?
Basically you'll want to get the field's value and do a str_replace(), but where?

I haven't done this myself yet, but I believe you'll have to create a normalizer.

Serialization API overview (good read).

I think you can achieve it by doing the following Changing the way Serializer handles entities.

There is more indepth info here Using Normalizers to Alter REST JSON Structure in Drupal 8.