SaaS CMS has officially launched! Learn more now.

Media Descriptor Attribute not supporting SVG file



IN episerver cms MediaDescriptot is not working svg type

[MediaDescriptor(ExtensionString = "jpg,jpeg,jpe,ico,gif,bmp,png,svg")]

got the below error message

Content with id '2714' is of type 'EPiServer.Core.ImageData_DynamicProxy' which does not inherit required type 'Models.Media.ImageFile

Can any one help on this issue.

Jun 08, 2021 15:27

When do you get this error, when trying to upload?

Should work although no note they say it won't work in the openable in the image editor

Jun 08, 2021 16:24

Hi Srini,

Can you paste the full stack trace here? What version of CMS NuGet packages you have installed in the solution (like EPiServer.CMS.Core version)?

To me it looks like the content with id '2714' is loaded as ImageData (but proxied, Episerver base class for content that is supposed to be images) and propably you are trying to use it as your content type 'Models.Media.ImageFile'.

If you login to edit mode and change the url so that you set that content id (2714) in edit mode url, does the edit mode load the image ok - what content type it shows for the image (and is this image really .svg?)

Or you could add somewhere in your code (some controller for example) that loads content with that id 2714 and then you could easily debug it in Visual Studio in your local environment (assuming you have the same data as the environment causing this issue).

If you have some 3rd party add-ons that add own image content types, it could be that your code gets messed up as there are more than one content type registered for SVG images by the mediadescriptorattribute - i think i once had a look at the Episerver code that decides which type it will use, and it is based on loading the types that can have for example SVGs and first one is picked up.

When this issue started - was it that you only added the "svg" to the MediaDescriptorAttribute or did you already have a content type for SVGs and just moved the SVG extension to this content type? So what was done when you started to have this issue?

Jun 14, 2021 15:53

How do you define your ImageFile (i.e. how does your class look like)?

Jun 15, 2021 7:39
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.