Example #1
0
        private ImageSizeModel DefaultThumbnailSize()
        {
            ImageSizeModel result;
            var            defaultThumbnail = VideoGalleryModel.DefaultThumbnailProfileName <VideoLibrary>();

            if (defaultThumbnail != null)
            {
                result = new ImageSizeModel()
                {
                    DisplayMode = ImageDisplayMode.Thumbnail,
                    Thumbnail   = new ThumbnailModel()
                    {
                        Name = VideoGalleryModel.DefaultThumbnailProfileName <VideoLibrary>()
                    }
                };
            }
            else
            {
                result = new ImageSizeModel()
                {
                    DisplayMode = ImageDisplayMode.Original
                };
            }

            return(result);
        }
Example #2
0
        private void GetThumbnailSizes(out int width, out int height, ImageSizeModel imageSizeModel)
        {
            width  = 0;
            height = 0;

            var thumbnailName = imageSizeModel.Thumbnail != null ? imageSizeModel.Thumbnail.Name : string.Empty;

            var thumbnailProfile = this.DefaultAlbumThumbnailProfile(thumbnailName);

            if (thumbnailProfile != null)
            {
                // Sets width - width is with higher priority if presents in parameters' collection
                if (thumbnailProfile.Parameters.Keys.Contains("Width"))
                {
                    width = this.GetThumbnailProfileSize(thumbnailProfile, "Width");
                }
                else if (thumbnailProfile.Parameters.Keys.Contains("MaxWidth"))
                {
                    width = this.GetThumbnailProfileSize(thumbnailProfile, "MaxWidth");
                }

                // Sets height - height is with higher priority if presents in parameters' collection
                if (thumbnailProfile.Parameters.Keys.Contains("Height"))
                {
                    height = this.GetThumbnailProfileSize(thumbnailProfile, "Height");
                }
                else if (thumbnailProfile.Parameters.Keys.Contains("MaxHeight"))
                {
                    height = this.GetThumbnailProfileSize(thumbnailProfile, "MaxHeight");
                }
            }
        }
        private void GetThumbnailSizesOrDefaultSizes(out int width, out int height, ImageSizeModel imageSizeModel, SfImage image)
        {
            width  = 0;
            height = 0;

            var thumbnailName = imageSizeModel.Thumbnail != null ? imageSizeModel.Thumbnail.Name : string.Empty;

            var thumbnailProfile = this.DefaultAlbumThumbnailProfile(thumbnailName);

            if (thumbnailProfile != null)
            {
                if (image.IsVectorGraphics())
                {
                    // Sets width - width is with higher priority if presents in parameters' collection
                    if (thumbnailProfile.Parameters.Keys.Contains("Width"))
                    {
                        width = this.GetThumbnailProfileSize(thumbnailProfile, "Width");
                    }
                    else if (thumbnailProfile.Parameters.Keys.Contains("MaxWidth"))
                    {
                        width = this.GetThumbnailProfileSize(thumbnailProfile, "MaxWidth");
                    }

                    // Sets height - height is with higher priority if presents in parameters' collection
                    if (thumbnailProfile.Parameters.Keys.Contains("Height"))
                    {
                        height = this.GetThumbnailProfileSize(thumbnailProfile, "Height");
                    }
                    else if (thumbnailProfile.Parameters.Keys.Contains("MaxHeight"))
                    {
                        height = this.GetThumbnailProfileSize(thumbnailProfile, "MaxHeight");
                    }
                }
                else
                {
                    var selectedThumbnail = image.Thumbnails.Where(t => t.Name == thumbnailProfile.Name).FirstOrDefault();

                    if (selectedThumbnail == null)
                    {
                        selectedThumbnail = LazyThumbnailGenerator.Instance.CreateThumbnail(image, thumbnailName);
                    }

                    if (selectedThumbnail != null)
                    {
                        width  = selectedThumbnail.Width;
                        height = selectedThumbnail.Height;
                    }
                }
            }
            else
            {
                //set dimensions to original size if no thumbnail profiles are found
                width  = image.Width;
                height = image.Height;
            }
        }
Example #4
0
        /// <summary>
        /// Gets the thumbnail URL for the selected size.
        /// </summary>
        /// <param name="video">The video.</param>
        /// <param name="sizeModel">The size model.</param>
        /// <returns></returns>
        protected virtual string GetSelectedSizeUrl(SfVideo video, ImageSizeModel sizeModel)
        {
            if (video.Id == Guid.Empty)
            {
                return(string.Empty);
            }

            var urlAsAbsolute = Config.Get <SystemConfig>().SiteUrlSettings.GenerateAbsoluteUrls;

            string videoThumbnailUrl;

            if (sizeModel.DisplayMode == ImageDisplayMode.Thumbnail && !string.IsNullOrWhiteSpace(sizeModel.Thumbnail.Name))
            {
                videoThumbnailUrl = video.ResolveThumbnailUrl(sizeModel.Thumbnail.Name, urlAsAbsolute);
            }
            else
            {
                videoThumbnailUrl = video.ResolveThumbnailUrl("0", urlAsAbsolute);
            }

            return(videoThumbnailUrl);
        }
Example #5
0
        /// <summary>
        /// Gets the selected size URL.
        /// </summary>
        /// <param name="image">The image.</param>
        /// <returns></returns>
        protected virtual string GetSelectedSizeUrl(SfImage image, ImageSizeModel sizeModel)
        {
            if (image.Id == Guid.Empty)
            {
                return(string.Empty);
            }

            string imageUrl;
            var    urlAsAbsolute = Config.Get <SystemConfig>().SiteUrlSettings.GenerateAbsoluteUrls;

            if (sizeModel.DisplayMode == ImageDisplayMode.Thumbnail && !string.IsNullOrWhiteSpace(sizeModel.Thumbnail.Name))
            {
                imageUrl = image.ResolveThumbnailUrl(sizeModel.Thumbnail.Name, urlAsAbsolute);
            }
            else
            {
                var originalImageUrl = image.ResolveMediaUrl(urlAsAbsolute);
                imageUrl = originalImageUrl;
            }

            return(imageUrl);
        }
Example #6
0
        private void ApplyThumbnailProfileToViewModel(ImageDetailsViewModel imageDetailsViewModel, ImageSizeModel imageSizeModel)
        {
            int width;
            int height;

            this.GetThumbnailSizes(out width, out height, imageSizeModel);

            if (height > 0)
            {
                imageDetailsViewModel.Height = height;
            }

            if (width > 0)
            {
                imageDetailsViewModel.Width = width;
            }
        }
Example #7
0
        private void ApplyImageSizesToViewModel(ThumbnailViewModel thumbnailViewModel, ImageSizeModel imageSizeModel)
        {
            int width;
            int height;

            this.GetThumbnailSizes(out width, out height, imageSizeModel);

            if (height > 0)
            {
                thumbnailViewModel.DetailsImageHeight = height;
            }

            if (width > 0)
            {
                thumbnailViewModel.DetailsImageWidth = width;
            }
        }
        private void ApplyThumbnailProfileToViewModel(ThumbnailViewModel thumbnailViewModel, ImageSizeModel imageSizeModel, SfImage image)
        {
            int width;
            int height;

            this.GetThumbnailSizesOrDefaultSizes(out width, out height, imageSizeModel, image);

            if (height > 0)
            {
                thumbnailViewModel.Height = height;
            }

            if (width > 0)
            {
                thumbnailViewModel.Width = width;
            }
        }