Module: Scrivito::BinaryRewrite

Defined in:
app/cms/scrivito/binary_rewrite.rb

Overview

This module lets you change the URL of a binary CMS object for the purpose of fetching the binary data from a different location (e.g. via a proxy or from a mirror).

Class Method Summary collapse

Class Method Details

.enable_for(request, &block) ⇒ Object

You can, for example, have the URLs of images, etc., point to your desired domain instead of to the CDN Scrivito uses.

Examples:

Scrivito::BinaryRewrite.enable_for(request) do |binary_url|
  binary_url.sub(
    /https:\/\/.+\.scrvt\.com\//,
    "https://my.reverse.proxy.com/")
end

Parameters:

  • request (ActionDispatch::Request)
  • block (Proc)

    block change default CDN url of current binary obj



31
32
33
# File 'app/cms/scrivito/binary_rewrite.rb', line 31

def self.enable_for(request, &block)
  request.env["SCRIVITO_BINARY_URL_CALLBACK"] = block
end