我制作了一个带有 ImageUrl 属性和 Description 属性的 ImageBlock。ImageUrl 是必需的。
[ContentType(
DisplayName = "Image",
Description = "Image with description and caption",
GUID = "387A029C-F193-403C-89C9-375A2A6BF028",
AvailableInEditMode = false)]
public class ImageBlock : BaseBlock
{
[Required]
[UIHint(UIHint.Image)]
[Display(
Name = "Image Url",
Description = "",
GroupName = SystemTabNames.Content,
Order = 10)]
public virtual Url ImageUrl { get; set; }
[Display(
Name = "Image Description",
Description = "A description of the image",
GroupName = SystemTabNames.Content,
Order = 20)]
public virtual string Description { get; set; }
}
我的 ArticlePage 将此 ImageBlock 用于其 Image 属性,但它不需要在文章中包含图像。但是,如果编辑器选择有图像,则 url 应该是必需的。
[Display(
Name = "Image",
Description = "",
GroupName = SystemTabNames.Content,
Order = 20)]
public virtual ImageBlock Image { get; set; }
但是,当我创建 ArticlePage 的新实例时,系统会提示我输入 EPiServer 声称需要的 ImageUrl。我错过了什么吗?