Пример #1
0
        protected virtual string GetSource()
        {
            var      options = new MediaUrlOptions();
            Language result1;

            if (!string.IsNullOrEmpty(language) && Language.TryParse(language, out result1))
            {
                options.Language = result1;
            }

            if (!string.IsNullOrEmpty(database))
            {
                options.Database = Factory.GetDatabase(database);
            }

            Version result2;

            if (Version.TryParse(version, out result2))
            {
                options.Version = result2;
            }

            options.Width  = width;
            options.Height = height;

            if (maxHeightSet)
            {
                options.MaxHeight = maxHeight;
            }

            if (maxWidthSet)
            {
                options.MaxWidth = maxWidth;
            }

            if (thumbnailSet)
            {
                options.Thumbnail = thumbnail;
            }

            if (scaleSet)
            {
                options.Scale = scale;
            }
            if (asSet)
            {
                options.AllowStretch = allowStretch;
            }
            if (!string.IsNullOrEmpty(backgroundColor))
            {
                options.BackgroundColor = MainUtil.StringToColor(backgroundColor);
            }
            options.IgnoreAspectRatio = ignoreAspectRatio;
            if (disableMediaCacheSet)
            {
                options.DisableMediaCache = disableMediaCache;
            }
            var urlString = imageField.MediaItem == null
                ? new UrlString(source)
                : new UrlString(MediaManager.GetMediaUrl(imageField.MediaItem, options));
            var parameters = new UrlString(options.ToString()).Parameters;

            foreach (var key in parameters.AllKeys)
            {
                urlString.Append(key, parameters[key]);
            }
            return(urlString.GetUrl(xhtml && Settings.Rendering.ImagesAsXhtml));
        }