/// <summary>
 ///     Initializes a new instance of the <see cref="PublishedElementWrapped" /> class
 ///     with an <c>IPublishedElement</c> instance to wrap.
 /// </summary>
 /// <param name="content">The content to wrap.</param>
 /// <param name="publishedValueFallback">The published value fallback.</param>
 protected PublishedElementWrapped(IPublishedElement content, IPublishedValueFallback publishedValueFallback)
 {
     _content = content;
     _publishedValueFallback = publishedValueFallback;
 }
 // ctor
 public Video(IPublishedContent content, IPublishedValueFallback publishedValueFallback)
     : base(content, publishedValueFallback)
 {
     _publishedValueFallback = publishedValueFallback;
 }
示例#3
0
 // ctor
 public DataFolder(IPublishedContent content, IPublishedValueFallback publishedValueFallback)
     : base(content, publishedValueFallback)
 {
     _publishedValueFallback = publishedValueFallback;
 }
        private static string?GetCropUrl(
            this IPublishedContent mediaItem,
            IImageUrlGenerator imageUrlGenerator,
            IPublishedValueFallback publishedValueFallback,
            IPublishedUrlProvider publishedUrlProvider,
            ImageCropperValue?localCrops,
            bool localCropsOnly,
            int?width                       = null,
            int?height                      = null,
            string propertyAlias            = Constants.Conventions.Media.File,
            string?cropAlias                = null,
            int?quality                     = null,
            ImageCropMode?imageCropMode     = null,
            ImageCropAnchor?imageCropAnchor = null,
            bool preferFocalPoint           = false,
            bool useCropDimensions          = false,
            bool cacheBuster                = true,
            string?furtherOptions           = null,
            UrlMode urlMode                 = UrlMode.Default)
        {
            if (mediaItem == null)
            {
                throw new ArgumentNullException(nameof(mediaItem));
            }

            if (mediaItem.HasProperty(propertyAlias) == false || mediaItem.HasValue(propertyAlias) == false)
            {
                return(null);
            }

            var mediaItemUrl = mediaItem.MediaUrl(publishedUrlProvider, propertyAlias: propertyAlias, mode: urlMode);

            // Only get crops from media when required and used
            if (localCropsOnly == false && (imageCropMode == ImageCropMode.Crop || imageCropMode == null))
            {
                // Get the default cropper value from the value converter
                var cropperValue = mediaItem.Value(publishedValueFallback, propertyAlias);

                var mediaCrops = cropperValue as ImageCropperValue;

                if (mediaCrops == null && cropperValue is JObject jobj)
                {
                    mediaCrops = jobj.ToObject <ImageCropperValue>();
                }

                if (mediaCrops == null && cropperValue is string imageCropperValue &&
                    string.IsNullOrEmpty(imageCropperValue) == false && imageCropperValue.DetectIsJson())
                {
                    mediaCrops = imageCropperValue.DeserializeImageCropperValue();
                }

                // Merge crops
                if (localCrops == null)
                {
                    localCrops = mediaCrops;
                }
                else if (mediaCrops != null)
                {
                    localCrops = localCrops.Merge(mediaCrops);
                }
            }

            var cacheBusterValue = cacheBuster ? mediaItem.UpdateDate.ToFileTimeUtc().ToString(CultureInfo.InvariantCulture) : null;

            return(GetCropUrl(
                       mediaItemUrl, imageUrlGenerator, localCrops, width, height, cropAlias, quality, imageCropMode, imageCropAnchor, preferFocalPoint, useCropDimensions,
                       cacheBusterValue, furtherOptions));
        }
 // ctor
 public EquipePage(IPublishedContent content, IPublishedValueFallback publishedValueFallback)
     : base(content, publishedValueFallback)
 {
     _publishedValueFallback = publishedValueFallback;
 }
 // ctor
 public UmbracoMediaAudio(IPublishedContent content, IPublishedValueFallback publishedValueFallback)
     : base(content, publishedValueFallback)
 {
     _publishedValueFallback = publishedValueFallback;
 }
示例#7
0
 /// <inheritdoc />
 /// <summary>
 /// Initializes a new instance of the <see cref="PublishedElementModel"/> class with
 /// an original <see cref="IPublishedElement"/> instance.
 /// </summary>
 /// <param name="content">The original content.</param>
 /// <param name="publishedValueFallback">The published value fallback.</param>
 protected PublishedElementModel(IPublishedElement content, IPublishedValueFallback publishedValueFallback)
     : base(content, publishedValueFallback)
 {
 }
 public TestElementModel1(IPublishedElement content, IPublishedValueFallback fallback)
     : base(content, fallback)
 {
 }
 public TestContentModel2(IPublishedContent content, IPublishedValueFallback fallback)
     : base(content, fallback)
 {
 }
示例#10
0
 // ctor
 public TextBlock(IPublishedContent content, IPublishedValueFallback publishedValueFallback)
     : base(content, publishedValueFallback)
 {
     _publishedValueFallback = publishedValueFallback;
 }
示例#11
0
 // ctor
 public ConventusItem(IPublishedElement content, IPublishedValueFallback publishedValueFallback)
     : base(content, publishedValueFallback)
 {
     _publishedValueFallback = publishedValueFallback;
 }
示例#12
0
 // ctor
 public ArticleItem(IPublishedContent content, IPublishedValueFallback publishedValueFallback)
     : base(content, publishedValueFallback)
 {
     _publishedValueFallback = publishedValueFallback;
 }
 // ctor
 public Speaker(IPublishedContent content, IPublishedValueFallback publishedValueFallback)
     : base(content, publishedValueFallback)
 {
     _publishedValueFallback = publishedValueFallback;
 }
示例#14
0
 // ctor
 public Gallery(IPublishedContent content, IPublishedValueFallback publishedValueFallback)
     : base(content, publishedValueFallback)
 {
     _publishedValueFallback = publishedValueFallback;
 }
 public ContentType2Sub(IPublishedContent content, IPublishedValueFallback fallback)
     : base(content, fallback)
 {
 }
 /// <summary>
 /// Gets a value indicating whether the content is visible.
 /// </summary>
 /// <param name="content">The content.</param>
 /// <param name="publishedValueFallback">The published value fallback implementation.</param>
 /// <returns>A value indicating whether the content is visible.</returns>
 /// <remarks>A content is not visible if it has an umbracoNaviHide property with a value of "1". Otherwise,
 /// the content is visible.</remarks>
 public static bool IsVisible(this IPublishedElement content, IPublishedValueFallback publishedValueFallback)
 {
     // rely on the property converter - will return default bool value, ie false, if property
     // is not defined, or has no value, else will return its value.
     return(content.Value <bool>(publishedValueFallback, Constants.Conventions.Content.NaviHide) == false);
 }
 public PublishedContentStrong1(IPublishedContent content, IPublishedValueFallback fallback)
     : base(content, fallback)
 {
 }
示例#18
0
 public AliasUrlProvider(IOptions <RequestHandlerSettings> requestConfig, ISiteDomainMapper siteDomainMapper, UriUtility uriUtility, IPublishedValueFallback publishedValueFallback, IUmbracoContextAccessor umbracoContextAccessor)
 {
     _requestConfig          = requestConfig.Value;
     _siteDomainMapper       = siteDomainMapper;
     _uriUtility             = uriUtility;
     _publishedValueFallback = publishedValueFallback;
     _umbracoContextAccessor = umbracoContextAccessor;
 }