Press Ctrl / CMD + C to copy this to your clipboard.
This post will be reported to the moderators as potential spam to be looked at
Hi All,
Was wondering if there's a way I can add a new media property (to the Image type) like a true/false property when an application start?
Need someone to point me to the right direction.
Thank you
Hi Johnny,
You can see more about startup events here:
https://our.umbraco.com/documentation/reference/events/application-startup
To update a media property you want to use IMediaTypeService and IDataTypeService which you can add to your class using Dependency Injection.
Once you have access to IMediaTypeService and IDataTypeService you can update the properties of a media type using:
var imageType = _mediaTypeService.Get("Image"); if (imageType != null) { //Add true false datatype var trueFalseDataType = _dataTypeService.GetDataType("True/false"); PropertyType myProperty = new PropertyType(trueFalseDataType ,"myProperty"); myProperty.Name = "My true false property"; imageType.AddPropertyType(myProperty , "Image"); _mediaTypeService.Save(imageType ); }
Thanks Marc,
Works accordingly
is working on a reply...
Write your reply to:
Upload image
Image will be uploaded when post is submitted
Umbraco 8 - Add new media property upon site load
Hi All,
Was wondering if there's a way I can add a new media property (to the Image type) like a true/false property when an application start?
Need someone to point me to the right direction.
Thank you
Hi Johnny,
You can see more about startup events here:
https://our.umbraco.com/documentation/reference/events/application-startup
To update a media property you want to use IMediaTypeService and IDataTypeService which you can add to your class using Dependency Injection.
Once you have access to IMediaTypeService and IDataTypeService you can update the properties of a media type using:
Thanks Marc,
Works accordingly
is working on a reply...