-
Notifications
You must be signed in to change notification settings - Fork 5
Configuring Sources
Jeremy Larkin edited this page May 3, 2012
·
1 revision
You will need to set up a source in your Imgix account. Depending on the type, you will then need to configure your model(s) to match either a Web Folder, Web Proxy, or S3. Typically, you will want to place the configuration in a YAML file in your config
directory (i.e. RAILS_ROOT/config/imgix.yml
). The contents can be either global:
type: …
domain_name: …
…
or environment specific:
development:
type: …
domain_name: …
…
test:
…
production:
…
Example:
type: webfolder
domain_name: webfolder_source_name
base_url: http://mysite.com/system/
secure_url_token: XXXXXXXX
-
type
: must bewebfolder
-
domain_name
: the subdomain name chosen when creating the source -
secure_url_token
: required if the source is configured to use secure URLs. This prevents the URLs from being modified from what you've created. The value must be the token set for the source. -
base_url
: the base URL set within the source. This can be just the path (/system/
), but if in doubt, just duplicate what you've set in the source.
Example:
type: webproxy
domain_name: webproxy_source_name
secure_url_token: XXXXXXXX
base_url: http://mysite.com/system/
-
type
: must bewebproxy
-
domain_name
: the subdomain name chosen when creating the source -
secure_url_token
: required if the source is configured to use secure URLs, which is highly recommended for web proxy sources. This prevents the URLs from being modified from what you've created. The value must be the token set for the source. -
base_url
: optional if anasset_host
is configured.
Because a Web Proxy source requires an absolute URL, some means of converting a path-only URL into a host-and-path URL is required. There are three ways to accomplish this:
- Set up an asset host (see below)
- Set the
base_url
key in the configuration - Make sure the paperclip
url
option is defined with a host.
If a host is not set, a Paperclip::Imgix::Errors::AssetHostRequired
exception will be raised.
In RAILS_ROOT/config/application.rb
:
config.action_controller.asset_host = "http://assets.mysite.com"
Example:
type: s3
domain_name: s3_source_name
secure_url_token: XXXXXXXX
prefix: /system/
-
type
: must bes3
-
domain_name
: the subdomain name chosen when creating the source -
secure_url_token
: required if the source is configured to use secure URLs. This prevents the URLs from being modified from what you've created. The value must be the token set for the source. -
prefix
: required if a prefix was chosen when setting up the source. If you did not set a prefix, omit this option.