Skip to the content
Documentation

Binary files URL handling: comparison of v.1 vs v.2

No ratings yet

Versions Compared

Old Version 1

changes.mady.by.user Bertrand Dunogier

Saved on Oct 31, 2014

compared with

New Version Current

changes.mady.by.user Dominika Kurek

Saved on Feb 02, 2016

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Status
colour Yellow
title 5.4 / 2014.09

IO URL decoration

By default, images and binary files referenced by content will be served from the same server than as the application, like /var/ezdemo_site/storage/images/3/6/4/6/6463-1-eng-GB/kidding.png. This is the default semantic configuration:

...

 $var_dir$ and $storage_dir$ are dynamic, siteaccess-aware settings, and will be replaced by those settings value in the execution context.

...

Warning
URL decorators are an eZ Publish 5 Platform features. If an image field is displayed via a legacy callback or legacy template, no decoration will be applied.

...

One common use-case is to use an optimized nginx to serve images in an optimized way. The example image above could be made available as http://static.example.com/images/3/6/4/6/6463-1-eng-GB/kidding.png, by setting up a server that uses exponential/exponential_legacy/var/ezdemo_site/storage. The eZ Publish Platform configuration would be as follows:

...

Info

Legacy compatiblity

Legacy still requires non-absolute path to store images (var/site/storage/images/etc...). In order to work around this, an a UrlRedecorator, that converts back and forth between the legacy uri prefix and the one in use in the application , has been added. It is used in all places where a legacy URL is returned/expected, and takes care of making sure the value is as expected.

...

Those settings are siteaccess-aware.

io.url_prefix

Default value: $var_dir$/$storage_dir$
Example: /var/ezdemo_site/storage

...

Used by the legacy storage engine to convert images public URI to a format it understands. Unlike io.url_prefix, it is not an absolute link. Can not Cannot be overridden using semantic configuration. Changing this value will break compatibility for the legacy backoffice.

...

Physical path where binary files are stored on disk. Can not Cannot be overridden using semantic configuration. Changing this value will break compatibility for the legacy backoffice.

Services

...

URL decorators

An UrlDecorator decorates and undecorates a given string (url) in some way. It has two mirror methods: decorate and undecorate.

Two implementations are provided: Prefix, and AbsolutePrefix. They both add a prefix to an a URL, but AbsolutePrefix will ensure that unless the prefix is an external URL, the result will be prepended with /.

...

  • exponential.core.io.prefix_url_decorator Used used by the binarydata handlers to decorate all uris sent out by the API. Uses AbsolutePrefix.
  • exponential.core.io.image_fieldtype.legacy_url_decorator Used used via the UrlRedecorator (see below) by various legacy elements (Converter, Storage Gateway, etc...) to generate its internal storage format for uris. Uses a Prefix, not an AbsolutePrefix, meaning that no leading / is added.

In addition, an a UrlRedecorator service, exponential.core.io.image_fieldtype.legacy_url_redecorator, uses both decorators abive above to convert URIs between what is used on the new stack, and what format legacy expects (relative urls from the exponential root).

 

Comments

Add a comment

Comments are read by a moderator before they appear.