Santa

Let’s Talk

We would love to hear from you. Want to know more about
our services or have any questions? Say Hi!

Top 3 ways to store media in Sitecore Media Library

June 26, 2023
Top 3 ways to store media in Sitecore Media Library
Juanita Xavier
Juanita Xavier
Project Manager
top-3-ways-to-store-media-in-sitecore-media-library

A website without media is more like a home without furniture.

Every website needs good media to make a website look more attractive. And with the help of media files, users can also easily understand concepts without even reading the content. Right?

So let’s talk about Media Library Concept in Sitecore.

Media Library is a place where you can store your media files whether it is an Image, Video, or Document.

In the Media Library, you can:

  • Keep all your media files in one place. After that you can organize them in a folder structure which can also be like the content tree.
  • Then you can navigate the content tree, or you can use Sitecore’s search functionality which will allow you to quickly find media items.
  • Upload media files to the Media Library.
  • This way, you can make every media content item and media file version-able.

After login in Sitecore, you will see this type of tree structure, where you will find the “Media Library” folder. Here you have to upload your media assets like image, video, document etc.

top-3-ways-to-store-media-in-sitecore-media-library-1

There are three ways to store Media Files in Sitecore.

  1. Sitecore Database
  2. File Storage (Physical File)
  3. Azure Blob Storage
  1. Store Media File into Sitecore Database:

    This is the default option to store the media files in Sitecore. When you upload any media file it will be stored in the Sitecore database. When you Delete the item from the media Library it will be deleted from the DB as well. Once you delete it there will be no any clue of having that file.

  2. Store Media File in File Storage / Store Media File as Physical location:

    Sometimes there is a requirement to store the file physically instead of through databases. That’s why Sitecore has also provided this functionality to store media files physically. This is not the default functionality but you can enable this feature by making some changes to Sitecore.config.

    • In Sitecore.config search for Media.UploadAsFiles.
    • The default value of the setting has been set to false for Media.UploadAsFiles as mentioned in the below screenshot. top-3-ways-to-store-media-in-sitecore-media-library-2
    • Change the value of Media.UploadAsFiles and set true.
    • The default path to store the media file has been set as /App_Data/MediaFiles you can change it as well.
    • To change the default storage path search for Media.FileFolder in Sitecore.config as mentioned in the below screenshot. top-3-ways-to-store-media-in-sitecore-media-library-3
    • In Media.FileFolder settings set your location path in the value attribute.

    Note: If you are storing Media files as physically and if you are deleting media items from Sitecore the physical file will not be deleted. Also, if you are deleting the file from a physical location your media item will not be deleted from the Sitecore Media Library.

  3. Store Media File in Azure Blob Storage:

    In Sitecore, all the media items are stored in the database as opposed to being saved in the file system and this is by default. You can also use the Azure blob storage module for storing media instead of the database.

    Below blog link to Enable the Azure Blob Storage module for Sitecore blobs: https://doc.sitecore.com/xp/en/developers/103/sitecore-experience-manager/enable-the-azure-blob-storage-module-for-sitecore-blobs.html

Now the questions are:

  1. If we are deleting the media library assets, will they also get deleted from Azure Blob?

    No, that will not happen. Although, the orphan blobs can be deleted from the Sitecore XP: (Control Panel > Administration tools > Database Cleanup > Database Name > Cleanup Blobs > Execute Cleanup)

  2. In the future, if we don’t want to continue with Blob Storage then can we migrate the Media Items to the Database?

    Yes, you can use Blob migration tool. Use the blob migration tool

  3. Can Azure Blob utilize the CDN that is provided by Managed Cloud Service to serve its assets?

    Yes, CDN is supported. Compatibility defined on the Sitecore XP level, not on media source. You can also manually configure the Sitecore Media Library for using the CDN The "Media.AlwaysIncludeServerUrl" and "Media.MediaLinkServerUrl" settings, media resources will directly point to CDN. The "Media.AlwaysAppendRevision" setting, and new updated media will have an updated URL, thus URL-based caching mechanism of a CDN working.

As per the above explanation, I hope you can choose the better options to store your media assets.


YOU MAY ALSO LIKE