Require user to use specific asset folder for image property on page

Vote:
 

Hi all,

I'm looking for an answer to the following question (or at least where to look in the forums/documentation, as I havent had any luck yet.):

I want to require a content author to select/upload images from a specific folder for a specific ContentReference property w/ UIHint.Image  on a page type. Basically the situation would be having a shared folder for a page type to store images in under the For All Sites media folder, for example: /For All Sites/LandingPage/SomeLandingPageSpecificImageFolder . 

Thanks!

#142917
Jan 05, 2016 22:42
Vote:
 

Heres an example of the code im working with that hopefully should be more clear.

[Display(
Name = "Page Banner",
Description = "The image appearing in the hero area.",
GroupName = SystemTabNames.Content,
Order = 300)]
[UIHint(UIHint.Image)]
public virtual ContentReference PageBanner{ get; set; }

I'd have a folder called /For All Sites/Landing Pages/Page Banners

I'd like to require the user, when editing the property PageBanner to be required to select an image or upload to the mentioned folder.

#142918
Jan 05, 2016 22:46
Vote:
 

I suppose you could solve this using Custom validation. Here is a couple of examples:

http://world.episerver.com/documentation/Items/Developers-Guide/Episerver-CMS/9/Content/Properties/Property-types/Writing-custom-attributes/

http://henrikm.com/custom-episerver-property-validation/

#142920
Jan 06, 2016 8:45
Vote:
 

Hello Timothy

I have not tried this with image selection but I think this post on changing the root for content references may contain the answer you are looking for:

https://gregwiechec.com/2015/12/changing-root-for-content-references-property/

Let me know how you get on.

David

#142929
Jan 06, 2016 12:03
Vote:
 

That sounds like a much better way to handle it than custom validation :-)

#142930
Jan 06, 2016 12:22
Vote:
 

I think thats pretty much exactly what I was looking for David, thank you very much. I figured this would be built in but it seems like a simple enough solution.

#142933
Jan 06, 2016 15:07
* 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.