Custom DAM provider and thumbnails

Overview

You can add custom DAM providers if you want to integrate Sitefinity CMS with a provider that is not supported by default.

Implementing custom DAM provider consists of two parts:

  • Server-side implementation of the custom DAM provider in Sitefinity CMS backend, which is covered in this article.
  • Client-side implementation of the custom DAM provider in Sitefinity CNS AdminApp via admin app extension. Documentation can be found in the AdminApp GitHub extensions repository.

The custom DAM provider must inherit DamBlobStorageProviderBase class. It has one abstract method that needs to be implemented: string GetItemThumbnailUrl (IBlobContentLocation content, ThumbnailArgs thumbnailArgs).
This method has two parameters:

  • content - the media content item stored in Sitefinity
  • thumbnailArgs - holding the thumbnail related information – width, height, quality, etc.

The method must return the thumbnail URL of the media content item. The URL of the asset is stored in content.FilePath property and must be updated according to the other parameter – <cod">thumbnailArgs considering the specifics of the DAM provider that you want to integrate with.</cod">

Sample implementation

Here is sample implementation of custom provider:

Each provider must have its corresponding configuration. The configuration class must implement IBlobStorageConfiguration interface. There are two methods that must be implemented:

The first one is IEnumerable<DataProviderSettings> GetProviderConfigElements(ConfigElement parent) as the assets are stored and managed by the DAM provider this one must return empty list.

The other one is IEnumerable<BlobStorageTypeConfigElement> GetProviderTypeConfigElements(ConfigElement parent). It returns the configuration type of the provider which will be added to the collection of all blob storage configurations. It returns enumerable of type BlobStorageTypeConfigurationElement. An object of that type needs to be created (in the constructor pass the input parameter parent) and return an enumerable containing only that object. The properties are:

  • Name - the name of the custom provider
  • ProviderType - the type of the custom provider
  • Title - the title of the configuration
  • Description - some description of the configuration
  • Parameters - property of type NameValueCollection which has the specific configuration values needed for the custom provider to work.

Here is sample implementation:

Where:

  • DamBlobStorageProviderBase.ScriptUrlKey is required for the integration to work. The script hosted on the specified URL will be loaded into the application in runtime and will load and open the assets selector of the DAM provider.
  • DamBlobStorageProviderBase.SupportedThumbnailFormatsKey is an optional parameter which defines what are the allowed extensions for the thumbnails.
  • CustomBlobStorageProvider.UrlKey is a parameter specific for our custom DAM provider and is required for opening the assets selector client side.
  • CustomBlobStorageProvider.ClientIdKey is parameter specific for our custom DAM provider and is required for opening the assets selector client side.

Finally, the provider type configuration must be registered in Sitefinity CMS. You can do that by attaching to RegisteringIoCTypes event of the ObjectFactory on Application_Start in your Global.asax.cs file:

After the configuration is registered in Sitefinity you will be able to add a provider of type CustomDamProvider by opening Administration » Settings » Storage providers » Add storage provider. The custom provider will be listed in the Provider type dropdown.

Override default DAM providers

If you want to modify the implementation of a default DAM provider, you can do so by registering a custom DAM provider following the steps listed above but instead of inheriting DamBlobStorageProviderBase you must inherit the provider which you want to override. Note that the name of the custom provider class must be the same as the one you want to override.

Custom thumbnails

You can choose from all (default and custom) thumbnail profiles for related images field if that image comes from DAM (Digital Asset Management) provider.

Here are the modifications that must be applied in the template

  1. In the beginning of the template add:
    @using Telerik.Sitefinity.Modules.Libraries;
  2. In the template update the part which displays the related images:

Increase your Sitefinity skills by signing up for our free trainings. Get Sitefinity-certified at Progress Education Community to boost your credentials.

Get started with Integration Hub | Sitefinity Cloud | Sitefinity SaaS

This free lesson teaches administrators, marketers, and other business professionals how to use the Integration hub service to create automated workflows between Sitefinity and other business systems.

Web Security for Sitefinity Administrators

This free lesson teaches administrators the basics about protecting yor Sitefinity instance and its sites from external threats. Configure HTTPS, SSL, allow lists for trusted sites, and cookie security, among others.

Foundations of Sitefinity ASP.NET Core Development

The free on-demand video course teaches developers how to use Sitefinity .NET Core and leverage its decoupled architecture and new way of coding against the platform.

Was this article helpful?