5

I want to patch only the ForceDownload attribute in below config:

<mediaLibrary>
    <mediaTypes>
        <mediaType name="PDF file" extensions="pdf">
            <mimeType>application/pdf</mimeType>
            <forceDownload>true</forceDownload>
            <sharedTemplate>system/media/unversioned/pdf</sharedTemplate>
            <versionedTemplate>system/media/versioned/pdf</versionedTemplate>
        </mediaType>
    </mediaTypes>
</mediaLibrary>

Please let me know, how to write the patch to make ForceDownload to false.

5

A slightly shortened version of the config Marek Musielak suggested can be achieved using patch:instead to replace the node with a new one:

<configuration xmlns:patch="http://www.sitecore.net/xmlconfig/">
  <sitecore>
    <mediaLibrary>
      <mediaTypes>
        <mediaType name="PDF file" extensions="pdf">
          <forceDownload patch:instead="forceDownload">false</forceDownload>
        </mediaType>
      </mediaTypes>
    </mediaLibrary>
  </sitecore>
</configuration>
3

You can remove the original forceDownload element and insert new one with false value.

  1. Create a patch file called MediaType.Pdf.Disable.ForceDownload.config.

  2. Edit the file and enter the following xml:

<configuration xmlns:patch="http://www.sitecore.net/xmlconfig/">
  <sitecore>
    <mediaLibrary>
      <mediaTypes>
        <mediaType name="PDF file" extensions="pdf">
          <forceDownload>
            <patch:delete />
          </forceDownload>
          <forceDownload>false</forceDownload>
        </mediaType>
      </mediaTypes>
    </mediaLibrary>
  </sitecore>
</configuration>
  1. Copy the file to App_Config\Include folder of your website or any of the subfolders of that folder.

More about patching can be read in the article:

https://doc.sitecore.com/developers/90/platform-administration-and-architecture/en/use-a-patch-file-to-customize-the-sitecore-configuration.html

1

To update element values like this, it's sufficient to just go down the unique path to the value you want to change, without specifying any patch attribute. This works just fine:

<configuration>
  <sitecore>
    <mediaLibrary>
      <mediaTypes>
        <mediaType name="PDF file">
          <forceDownload>false</forceDownload>
        </mediaType>
      </mediaTypes>
    </mediaLibrary>
  </sitecore>
</configuration>

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.