Currently I have a GrahpQL query with bunch of images returning src as "/-/media"


field(name:"Image"){ ...on ImageField{src} } 


"Image": {
        "src": "/-/media/images/abc.ashx",

Is there a way to get custom media prefix (without ~ or -. Just like "/customname/images...")?

  • The result you are receiving is the proper path for Sitecore to resolve it. If you want to change that to a custom path you may need to look into a solution involving a CDN. Commented Mar 23, 2022 at 22:02
  • Thank you @MichaelWest. Unfortunately we don't have a CDN setup.
    – Sun
    Commented Mar 25, 2022 at 12:29

2 Answers 2


Since we don't have a CDN url setup. I created this patch file and now I am getting results as expected.

<?xml version="1.0" encoding="utf-8" ?>
<configuration xmlns:patch="http://www.sitecore.net/xmlconfig/"> 
  <setting name="Media.RequestExtension"> 
   <patch:attribute name="value"></patch:attribute> 
  <setting name="Media.MediaLinkPrefix"> 
   <patch:attribute name="value">customname</patch:attribute> 
  <handler trigger="/customname/" handler="sitecore_media.ashx"/> 

Now I am getting below results:

"Image": {
            "src": "/customname/images/abc.jpg",

You can create a zz.CDN.enabler.config with the following settings to enable the CDN.

<setting name="Media.AlwaysIncludeServerUrl" value="true"/>
<setting name="Media.MediaLinkServerUrl" value="[you need to put the CDN url]"/>
<setting name="Media.AlwaysAppendRevision" value="false"/>
<setting name="MediaResponse.Cacheability" value="Public"/>
<setting name="MediaResponse.MaxAge" value="7.00:00:00"/>

and then web.config add the following setting it gives media urls a relevant extension like .jpg

<setting name="Media.RequestExtension" value=""/>
  • Thank you Sanjay and Sumit. Unfortunately we don't have CDN url setup.
    – Sun
    Commented Mar 25, 2022 at 12:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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