AI OnAI Off
You may be able to add an IModelTransform to your services to set the thumbnail. We integatrated 3rd party videos and used the thumbnails from them to display in admin:
services.AddTransient<IModelTransform, CustomVideoModelTransform>();
/// <summary>
/// Transformer to provider a thumbnail url to the editor area.
/// This allows us to not store thumbnails content in the repository
/// </summary>
public class CustomVideoModelTransform : TransformBase<StructureStoreContentDataModel>
{
/// <inheritdoc/>
public override void TransformInstance(IContent source, StructureStoreContentDataModel target, IModelTransformContext context)
{
if (source is CustomVideoVideoData video)
{
if (video.ThumbnailUrl != null && !video.ThumbnailUrl.IsEmpty())
{
target.ThumbnailUrl = video.ThumbnailUrl.OriginalString;
}
}
}
}
Thanks for the suggestion.
We ended up adding a thumbnail to the media property, then we needed to implement our own IContentCapability, see example
using EPiServer.Cms.Shell.UI.Rest.Capabilities;
using EPiServer.Core;
using EPiServer.ServiceLocation;
namespace Gosso.Plugins.Optimizely.Media;
[ServiceConfiguration(typeof(IContentCapability))]
public class GenerateThumbnailCapability : IContentCapability
{
private readonly IMyMediaHandlerResolver _myMediaHandlerResolver;
public string Key => "generateThumbnail";//important
public int SortOrder => 10;
public GenerateThumbnailCapability(IMyMediaHandlerResolver myMediaHandlerResolver)
{
_myMediaHandlerResolver = myMediaHandlerResolver;
}
public bool IsCapable(IContent content)
{
if (content is MediaData mediaData and IMyMedia myMedia)
{
if (mediaData.Thumbnail is null)
{
return false;
}
var fileInfo = new FileInfo(myMedia.Name);
var mediaHandler = _myMediaHandlerResolver.Resolve(fileInfo.Extension); //custom code
if (mediaHandler is not null)
{
return true;
}
}
if (content is not ImageData imageData ||
imageData.BinaryData is null ||
imageData.ContentLink.IsExternalProvider)
{
return false;
}
return true;
}
}
Latest CMS 12
Does anyone now if it is possible to add thumbnail instead of icon in the UIHint.Image property? when it is not an image (pdf or video)
Is that done by adding an image in thumbnail blob on media object maybe?