Uploaded image for project: 'CiviCRM'
  1. CiviCRM
  2. CRM-21086

Allow Inline View of Files Instead of Download

    Details

    • Type: Patch
    • Status: Done/Fixed
    • Priority: Trivial
    • Resolution: Fixed/Completed
    • Affects Version/s: 4.7.23
    • Fix Version/s: 4.7.25
    • Component/s: Core CiviCRM
    • Labels:
    • Versioning Impact:
      Patch (backwards-compatible bug fixes)
    • Documentation Required?:
      None
    • Funding Source:
      Contributed Code
    • Verified?:
      No
    • How it works currently:
      Files served from /civicrm/file will always be downloaded.
    • How it should work:
      Files served from /civicrm/file with the query param download=0 will be shown inline in the browser, if the browser supports it.
    • Acceptance Criteria:
      It is possible to create links to files that will be shown in the browser using the /civicrm/file endpoint.

      Description

      CRM_Core_Page_File is used to download files. Internally it uses CRM_Utils_System::download to fetch the file. This method has a parameter to set the content disposition. It defaults to "download" which forces the browser to download the file.

      To allow more flexibility, I suggest adding a check for a query parameter "download" here. It will default to 1, keeping backward compatibility, but for someone who sets "download=0" the content disposition will be "inline". This will allow using the same endpoint to view the file inline in the browser.

        Attachments

          Activity

            People

            • Assignee:
              monish.deb Monish Deb
              Reporter:
              michael Michael Devery
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: