Make sure My Domain is enabled in your org.
Check the below URL, if My Domain is not enabled.
https://www.infallibletechie.com/2013/04/how-to-register-domain-instead-of.html
Image – https://mydomain–c.documentforce.com/servlet/servlet.ImageServer?id={id}&oid={OrgId}
PDF – https://mydomain–c.documentforce.com/servlet/servlet.FileDownload?file={id}