Is there any way by which I can add a query string in each media item requested in SXA include CSS, js, images, fonts, etc.

Current URL - http://us.dev.local/-/media/base-themes/core-libraries/scripts/ie-origin-fix.js Required URL - http://us.dev.local/-/media/base-themes/core-libraries/scripts/ie-origin-fix.js?sc=1



You can implement a custom Sitecore.Resources.Media.MediaProvider. For example

public class MediaProvider : Sitecore.Resources.Media.MediaProvider

    public override string GetMediaUrl(MediaItem item, MediaUrlOptions options)
        var url = base.GetMediaUrl(item, options);

        url = WebUtil.AddQueryString(url, "sc", "1");

        return url;


Config patch

        patch:instead="mediaProvider[@type='Sitecore.Resources.Media.MediaProvider, Sitecore.Kernel']"/>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.