November Happy Hour will be moved to Thursday December 5th.
AI OnAI Off
November Happy Hour will be moved to Thursday December 5th.
What if you create an ImageData class for each filetype, then set the AllowedTypes to use those classes?
Start with a base class, for all image-related properties:
public abstract class BaseImageData : ImageData { public virtual string AltText { get; set; } }
Create image classes for each extension type:
[ContentType(GUID = "3016768f-180c-425c-97f7-e0a3dcbef9b7")] [MediaDescriptor(ExtensionString = "jpg")] public class JpgImageFile : BaseImageData { } [ContentType(GUID = "06e55dad-95da-44c5-a551-3cfbc820d853")] [MediaDescriptor(ExtensionString = "gif")] public class GifImageFile : BaseImageData { } [ContentType(GUID = "e476f5c3-d2d6-4659-9134-14c3c8b7efd3")] [MediaDescriptor(ExtensionString = "png")] public class PngImageFile : BaseImageData { }
Then use those classes in the AllowedTypes:
[ContentType(GUID = "d7a0797e-241a-410e-b35e-bb600aefec9b")] public class StandardPage : PageData { [AllowedTypes(new[] { typeof(JpgImageFile), typeof(PngImageFile) })] public virtual ContentReference Poster { get; set; } }
Is there a way to only allow specific file types in the ContentReference property? For example below, I only want to allow JPG and PNG, no GIFs (even though GIFs are allowed elsewhere on the site.
[Pasting files is not allowed]