Developer's Guide - EPiServer World
Developer's Guide - EPiServer World
Developer's Guide - EPiServer World
Create successful ePaper yourself
Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.
88 | Developer’s <strong>Guide</strong> <strong>EPiServer</strong> Community 3.1<br />
First we need the Image from where we extract the Thumbnail. This is done via the ImageGalleryHandler:<br />
Image image = ImageGalleryHandler.GetImage( 1234 );<br />
Now we use the GetThumbnail method in the Image class to get a Thumbnail where we specify the height and width.<br />
Thumbnail thumb =<br />
image.GetThumbnail(100, 100, ThumbnailFormat.Proportional);<br />
The available ThumbnailFormat properties are Proportional, ExactandReduceAndCrop. ThumbnailFormat.Proportional<br />
scales the image so that its proportions are intact. Therefore you cannot expect to get an image size of 100 by 100.<br />
ThumbnailFormat.Exactstretches the image if necessary to an image size of 100 by 100.<br />
ThumbnailFormat.ReduceAndCrop makes sure you get a 100 by 100 image by cropping it if necessary.<br />
We may now use the Url property in the Thumbnail class to display the image on a web page.<br />
2.20.7 Getting Images in an Image Gallery<br />
To get images from an ImageGallery to anImageCollection we use the GetImages method in the ImageGallery class.<br />
Import Necessary Namespaces<br />
First import the necessary namespaces that will be used to manage image galleries. The namespace<br />
StarCommunity.Modules.ImageGallery is described by clicking on its name. Make sure you add the assemblies as a<br />
reference, mentioned in Setting up Visual Studio.<br />
using StarCommunity.Modules.ImageGallery;<br />
First we get the ImageGallery that contains our images. This is done via the ImageGalleryHandler class:<br />
ImageGallery imageGallery = ImageGalleryHandler.GetImageGallery( 1234 );<br />
We get the images in the image gallery imageGallery. We take page 1 with 20 items per page sorting on image name<br />
ascending:<br />
int totalHits = 0;<br />
ImageCollection ic =<br />
imageGallery.GetImages(1, 20, out totalHits,<br />
new ImageSortOrder(ImageSortField.Order, SortDirection.Ascending));<br />
© <strong>EPiServer</strong> AB