Thumbnail format
The thumbnail format will result in an image even if the media itself is not convertible to an image. If no converter is able to create a thumbnail image, the IconConverter will produce a image that represents the media file type.
To request a thumbnail using the declarative model you create a property of type Thumbnail.
public class GalleryImage : MediaItem {
[ResizeEffect(Width = 200)]
public Thumbnail Thumbnail { get; set; }
}
When retrieving the item you can get the URL of the content and all other properties that exists on the MediaItem class.
var client = clientFactory.GetSdkClient();
var galleryImages = client.Query<GalleryImage>().Where(m => m.VaultId == 30)
.OrderBy(m => m.DateAdded).Take(20).ToList();
foreach (var galleryImage in galleryImages) {
_testOutputHelper.WriteLine(galleryImage.Name + "," + galleryImage.Thumbnail.Url);
}
Custom thumnail for video
As default, the thumbnail for a video asset will calculate the "best" frame to use as thumbnail. If you would like to take more control of what frame to use when generating the tumbnail, you can use the TrimEffect to specify a specific frame to use.
//create a Thumbnail format (ImageFormat is also ok)
var format = new ThumbnailFormat();
//with a trim effect that narrows down the video timeline
format.Effects.Add(new TrimEffect(37, 41));
//specify size effect
format.Effects.Add(new ResizeEffect(300, 300));
//Load the video but supply the custom format to make a thumbnail
var item = client.Load<Thumbnail>(11477).UseFormat(format).FirstOrDefault();