/// <summary> /// NOTE: New implementation of the legacy GetLinkValue. This is however a bit quirky as a media item can have multiple "Linkable DataTypes". /// Returns the value for a link in WYSIWYG mode, by default only media items that have a /// DataTypeUploadField are linkable, however, a custom tree can be created which overrides /// this method, or another GUID for a custom data type can be added to the LinkableMediaDataTypes /// list on application startup. /// </summary> /// <param name="entity"></param> /// <returns></returns> internal virtual string GetLinkValue(UmbracoEntity entity) { foreach (var property in entity.UmbracoProperties) { if (LinkableMediaDataTypes.Contains(property.DataTypeControlId) && string.IsNullOrEmpty(property.Value) == false) { return(property.Value); } } return(""); }
/// <summary> /// Returns the value for a link in WYSIWYG mode, by default only media items that have a /// DataTypeUploadField are linkable, however, a custom tree can be created which overrides /// this method, or another GUID for a custom data type can be added to the LinkableMediaDataTypes /// list on application startup. /// </summary> /// <param name="dd"></param> /// <param name="nodeLink"></param> /// <returns></returns> public virtual string GetLinkValue(Media dd, string nodeLink) { var props = dd.GenericProperties; foreach (Property p in props) { Guid currId = p.PropertyType.DataTypeDefinition.DataType.Id; if (LinkableMediaDataTypes.Contains(currId) && string.IsNullOrEmpty(p.Value.ToString()) == false) { return(p.Value.ToString()); } } return(""); }
/// <summary> /// NOTE: New implementation of the legacy GetLinkValue. This is however a bit quirky as a media item can have multiple "Linkable DataTypes". /// Returns the value for a link in WYSIWYG mode, by default only media items that have a /// DataTypeUploadField are linkable, however, a custom tree can be created which overrides /// this method, or another GUID for a custom data type can be added to the LinkableMediaDataTypes /// list on application startup. /// </summary> /// <param name="entity"></param> /// <returns></returns> internal virtual string GetLinkValue(UmbracoEntity entity) { foreach (var property in entity.AdditionalData .Select(x => x.Value as UmbracoEntity.EntityProperty) .Where(x => x != null)) { //required for backwards compatibility with v7 with changing the GUID -> alias var controlId = LegacyPropertyEditorIdToAliasConverter.GetLegacyIdFromAlias(property.PropertyEditorAlias, LegacyPropertyEditorIdToAliasConverter.NotFoundLegacyIdResponseBehavior.ReturnNull); if (controlId != null) { if (LinkableMediaDataTypes.Contains(controlId.Value) && string.IsNullOrEmpty((string)property.Value) == false) { return(property.Value.ToString()); } } } return(""); }