31.10.2014 Views

Developer's Guide - EPiServer World

Developer's Guide - EPiServer World

Developer's Guide - EPiServer World

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

86 | Developer’s <strong>Guide</strong> <strong>EPiServer</strong> Community 3.1<br />

Note that the image object at this point only exists in memory, and we need to call the AddImage method in the<br />

ImageGalleryHandler to commit it:<br />

image = ImageGalleryHandler.AddImage( image );<br />

Note that the AddImage method returns the committed object with the unique ID property set.<br />

2.20.4 Removing an Image<br />

Removing an existing image is done via the ImageGalleryHandler.<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 Image object to remove:<br />

Image image = ImageGalleryHandler.GetImage( 1234 );<br />

Then we remove it:<br />

ImageGalleryHandler.RemoveImage( image );<br />

2.20.5 Crop and Rotate an Image<br />

The image Crop and Rotate90 methods are located in the ImageActionHandler class in the<br />

StarCommunity.Modules.ImageGallery.<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 need to get an Image to edit. This is done using the GetImage method in the ImageGalleryHandler class. At the<br />

same time we create an instance of the ImageActionHandler to access the crop and rotate methods:<br />

Image image = ImageGalleryHandler.GetImage( 1234 );<br />

© <strong>EPiServer</strong> AB

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!