Try our conversational search powered by Generative AI!

Use a custom property in a page type


I made a class which inherits from ImageData:

[ContentType(GUID = "584F4521-65A3-4C77-BF9A-677A124FDFA9")]
[MediaDescriptor(ExtensionString = "jpg,jpeg,jpe,ico,gif,bmp,png")]
public class ImageFile : ImageData
    public virtual int Height { get; set; }
    public virtual int Width { get; set; }
   public virtual string Title { get; set; }

I am using it as a property for a page as below:

[Display(Name = "Sample",Description = "They display images of the samples.",GroupName = SystemTabNames.Content,Order = 10)]


public virtual ImageFile SampleImage { get; set; }

But when I try and run the application it gives me an error: 'ImageFile' could not be mapped to a PropertyDefinitionType

Am I missing any attribute to map this?

Edited, Feb 23, 2018 16:37

Hi, the 'ImageFile' that you have created is a content type and not a property type. See the Episerver documentation about how to create custom property types.

To use the image on a page type as property you need to use the ContentReference type for the property and optionally you can limit what kind of content can be referenced in the property.

For example like this on a page type:

[AllowedTypes(new Type[] { typeof(ImageFile) })] // allow only your ImageFile type here
public virtual ContentReference MyImageProperty { get; set; }
Feb 24, 2018 10:53
This topic was created over six months ago and has been resolved. If you have a similar question, please create a new topic and refer to this one.
* 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.