Unable to upload image in a block.

Vote:
 

Hi,

I'm getting image upload failed message (Content type "ImageFile" is not allowed to be created under parent of content type "BannerBlock".

For my home page, I have added a banner block. In banner block, I have an image property. Sharing the code:

public class BannerBlock : SiteBlockData
{
    [Display(
        GroupName = SystemTabNames.Content,
        Order = 1
    )]
    [CultureSpecific]
    [UIHint(UIHint.Image)]
    public virtual ContentReference Image { get; set; }

}

I have referred the documentation and EpiAlloy project to create all relevant models\controllers\viewmodels\rendering etc. for my blank project. But still not able to upload the file in the block.

Could someone please guide what could be the reason?

#210412
Nov 22, 2019 1:43
Vote:
 

Add this for allwing image in your property

[AllowedTypes(typeof(EPiServer.Core.ImageData))]

This allows the types that you want editor to permit to add in CMS. YOu can read more about attribute here

https://world.episerver.com/documentation/developer-guides/CMS/Content/Properties/property-attributes/

#210414
Nov 22, 2019 4:59
Bidya Bhusan Hota - Nov 22, 2019 22:23
Thanks a lot. It worked. :)
* 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.