contextualcode/ezplatform-content-disposition-bundle

eZ Platform bundle that gives the ability to specify content dispositions for downloads.

v2.3.1 2021-02-16 10:26 UTC

README

This bundle gives the ability to customize content dispositions (inline or attachment) for downloads.

You can specify the default content disposition, and content dispositions per mime type.

Installation

  • Run composer require:
$ composer require contextualcode/ezplatform-content-disposition-bundle
  • Enable this bundle in config/bundles.php by adding this line:
    return [
        ...,
        ContextualCode\EzPlatformContentDispositionBundle\ContextualCodeEzPlatformContentDispositionBundle::class => ['all' => true],
    ];

Usage

In some parameters block, for example in config/services.yaml, you can specify:

  • A default content disposition:

    ezsettings.global.download_content_disposition.default: inline
    
  • A content disposition per mimetype:

    ezsettings.global.download_content_disposition.mimetype:
      "application/pdf": inline
      "application/msword": attachment
    
  • Make files cache-control: public, s-maxage=%download_content_disposition.download_file_ttl% and vary by user context hash (default: false).

    ezsettings.default.download_content_disposition.public_download: true
    ezsettings.default.download_content_disposition.download_file_ttl: 86400
    

    if download_content_disposition.download_file_ttl setting not defined, content.default_ttl will be used.