help.axcms.net Axinom Logo

Thumbnails

With a new (9.2) thumbnailing concept every AxCMS.net object can have a thumbnail attached. You as a developer can define thumbnail generation logic.

Thumbnailing is a new feature of AxCMS.net version 9.2 that allows a developer to easily create and access thumbnails. AxCMS.net version 9.2 uses the new thumbailing features for generating the thumbnails for AxDocuments. As a developer you are free to use it for creating and managing thumbnails for your custom objects too.

Thumbnails are internally created using the image formats introduced in AxCMS.net version 9.1.

Thumbnail Sizes

Thumbnails in AxCMS.net always exist in two sizes. A small thumbnail that has a maximum size of 92x32 pixels and a big thumbnail that has a maximum size of 92x62 pixels.

How to make a custom object “thumbnailable”

If you have an object and like to have thumbnails for it, you can use the built in functionality of AxCMS.net for it. For that your class needs to implement the Axinom.AECMS.Thumbnails.IThumbnailable interface.

This interface defines the following properties and methods:
Bitmap GetImage();

The GetImage() method is called, when a thumbnail should be created. The returned image will be used by AxCMS.net to create the two different thumbnail sizes based on it. All thumbnails will display the content of the image returned by this function.

This method can return null. If null is returned, the fallback thumbnails that are defined below will be used as thumbnails for the object.
string ThumbFileName { get; }

This property defines how the thumbnail files are called. This must be unique for each object, to avoid naming problems in the file system.
string ThumbnailSubDirectory { get; }

The ThumbnailSubDirectory property defines the subdirectory in which the thumbnails for this object type will be stored. This path is relative to the upload directory of your CMS. To avoid naming problems in the file system, we recommend using a separate (sub-) directory for each object type.
string BigFallbackThumbPath { get; }

If GetImage() returns null, this image will be used as a big thumbnail.
string SmallFallbackThumbPath { get; }

If GetImage() returns null, this image will be used as a small thumbnail.
bool PublishThumbnails { get; }

This property defines whether the thumbnail should be published or not. If you don’t choose to publish the Thumbnails, the thumbnails will be created in LS when you use them first.

Note: Your publishing process must take care of this flag and publish the Thumb or not. Publishers for default CMS objects are already aware of this flag.

How to use thumbnails

To create thumbnails or get Thumbnail URLs you can use the Axinom.AECMS.Thumbnails. AxThumbnailManager.

AxThumbnailManager offers the following public functions:
string GetOrCreateThumbnail(IThumbnailable element, ThumbnailSizes size)

This function will return the filepath of the thumbnail of the defined size for an IThumbnailable. If the thumbnails do not exist, it will create the thumbnails.
string GetOrCreateThumbnailUrl(IThumbnailable element, ThumbnailSizes size)

This function does the same as GetOrCreateThumbnail, but returns the Url instead of the filepath.
void RecreateThumbnails(IThumbnailable element)

This funcion can be used to force the recreation of the thumbnails, e.g. if there is a new image that should be used as a thumbnail.
void RemoveThumbnails(IThumbnailable element)

This function removes the thumbnails from the file system.