Exemplo n.º 1
0
        protected void LoadImageVersions()
        {
            if (this.imageData != null)
            {
                foreach (var image in this.imageData.Where(x => x.fileExists))
                {
                    if (image.height == null || image.width == null)
                    {
                        GetOriginalSize(image);
                    }

                    ImagePath    originalImagePaths = new ImagePath(rootPath, this.galleryPath, image.imageName);
                    ImageSize    originalImageSize  = new ImageSize(image.height ?? 0, image.width ?? 0, CropType.None);
                    ImageVersion originalImage      = new ImageVersion(ImageVersionTypes.OriginalSize, originalImageSize, originalImagePaths);
                    image.Versions.Add(originalImage);

                    if (image.lightBox)
                    {
                        var       defaultWidth      = this.maxDefaultWidth < this.maxPopupWidth ? this.maxDefaultWidth : this.maxPopupWidth;
                        ImageSize desktopImageSize  = ImageSize.CalculateSize(originalImageSize, 0, defaultWidth, 1, CropType.None);
                        ImagePath desktopImagePaths = new ImagePath(rootPath,
                                                                    this.site + "/images", "thumb_h" + desktopImageSize.height + "_w" + desktopImageSize.width + "_" + image.imageName, originalImage);
                        ImageVersion desktopMaxImage = new ImageVersion(ImageVersionTypes.DesktopMaxSize, desktopImageSize, desktopImagePaths);
                        desktopMaxImage.CreateThumbnail();
                        image.Versions.Add(desktopMaxImage);

                        if (mobileLightBoxRequired)
                        {
                            ImageSize mobileMaxImageSize = ImageSize.CalculateSize(originalImageSize, 0, this.maxMobileWidth, 1, CropType.None);
                            ImagePath mobileImagePaths   = new ImagePath(rootPath,
                                                                         this.site + "/images", "thumb_h" + mobileMaxImageSize.height + "_w" + mobileMaxImageSize.width + "_" + image.imageName, originalImage);
                            ImageVersion mobileMaxImage = new ImageVersion(ImageVersionTypes.MobileMaxSize, mobileMaxImageSize, mobileImagePaths);
                            mobileMaxImage.CreateThumbnail();
                            image.Versions.Add(mobileMaxImage);
                        }
                    }

                    ImageSize desktopForGalleryImageSize = ImageSize.CalculateSize(originalImageSize, this.maxDefaultHeight,
                                                                                   this.maxDefaultWidth, this.desktopImagesAcrossPage, this.crop);
                    ImagePath desktopForGalleryImagePaths = new ImagePath(rootPath, this.site + "/images",
                                                                          "thumb_h" + desktopForGalleryImageSize.height + "_w" + desktopForGalleryImageSize.width + "_" + image.imageName, originalImage);
                    ImageVersion desktopForGalleryImage = new ImageVersion(ImageVersionTypes.DesktopForGallery, desktopForGalleryImageSize, desktopForGalleryImagePaths);
                    desktopForGalleryImage.CreateThumbnail(this.cropfrom);
                    image.Versions.Add(desktopForGalleryImage);

                    ImageSize mobileForGalleryImageSize = ImageSize.CalculateSize(originalImageSize, this.maxMobileHeight,
                                                                                  this.maxMobileWidth, this.mobileImagesAcrossPage, this.crop);
                    ImagePath mobileForGalleryImagePaths = new ImagePath(rootPath, this.site + "/images",
                                                                         "thumb_h" + mobileForGalleryImageSize.height + "_w" + mobileForGalleryImageSize.width + "_" + image.imageName, originalImage);
                    ImageVersion mobileForGalleryImage = new ImageVersion(ImageVersionTypes.MobileForGallery, mobileForGalleryImageSize, mobileForGalleryImagePaths);
                    mobileForGalleryImage.CreateThumbnail(this.cropfrom);
                    image.Versions.Add(mobileForGalleryImage);
                }
            }
        }
Exemplo n.º 2
0
 public ImageVersion(ImageVersionTypes versionType, ImageSize imageSize, ImagePath paths)
 {
     this.versionType = versionType;
     this.imageSize   = imageSize;
     this.paths       = paths;
 }