Assets from Digizuite can be rendered like any other assets in Optimizely either in Content Areas (using the included default controllers) or in XHTML properties or properties are either of the type ContentReference or Url.
...
The code above will be shown to the editor as seen below.
The images that are marked as UIHint.Image will render with the image selector - whether their underlying type is ContentReference or Url. However, if you simply add a Url without a UIHint you will get a selector that can also point to external urls as well (see example below).
...
Notice how Digizuite has it's own selector in the Url selection.
If you decide to use the Image editor descriptor, you'll be browsing the media library using the dialog seen here. Even though you in this case access the entire media structure - including Optimizely's 'own' media, the Digizuite folders will be available below the Digizuite folder (a name that can be customized in configuration.
Add Link dropdown.
...
Default Controllers
As mentioned earlier, just as the integration comes with default models, it also comes with default controllers so that it will work out-of-the-box when you drag in Digizuite assets into for example a content area. They exist for both images and videos.
...
A common task is to ensure that the proper media format for any given media asset is delivered. The media format can either be directly controlled in code, as we will see further down, it can be managed by editors in the XHTML fields, but you can also set up rules as a developer to connect it with Optimizely's rendering tags - just like the default controllers above takes into consideration. Read more about the rendering tags here: DFO 4.0.0 - 7 Dealing with Media Formats and Rendering Tags
Understanding URLs
As mentioned in the chapter DFO 4.0.0 - 2 Modelling Asset Content Types, you can assign Blob properties on your custom models to different media formats, so that when you render them you can simply call /[path to asset]/[Blob property name]. So, if you had a small media format, mapped to a "Small" property blob on the content model, you could simply call /[path to asset]/Small to get the small media format. In fact, the default Image class contains both Small, Medium and LargeThumbnail, just as the default Video contains "Preview" (lightweight version of the video), "Poster" (it's a full size single frame) and an "ImagePreview".
There are also some hardcoded options you can add to the URL, namely:
"/Download" to download the asset.
"/Source" to fetch the original source of the asset. This comes in handy when using SVG logos, where you typically want the source, rather than an image format.
It's also possible to specify the media format id directly by adding a url parameter called "mediaformatid", E.g. /globalassets/en/digizuite/5272-blueberry.jpg?mediaformatid=50034.
...
To fetch the right media formats we have created some extension methods that come in handy.
UrlHelper
...
extension
We have extended the UrlHelper in MVC, so you can easily in your razor templates use it, not only to get the ContentUrl, but also to get the url to an asset with the proper media format.
public static string DigizuiteMediaUrl(this UrlHelper urlHelper, IContentData model, Expression<Func<IContentData, ContentReference>> propertyExpression, object additionalParam = null)
The additionalParam can be
...
a
formatid: 50034 | 50035 | 50036 | 50037
e.g. <img src="@Url.DigizuiteMediaUrl(Model.CurrentPage, x => Model.CurrentPage.BannerImage, 50034)" />
formatname: Big | Medium | Small | Transparent
e.g. <img src="@Url.DigizuiteMediaUrl(Model.CurrentPage, x => Model.CurrentPage.ImageFormatMedium, "medium")" />
tagging: span12 | span8 | span6 | span4
e.g. <img src="@Url.DigizuiteMediaUrl(Model.CurrentPage, x => Model.CurrentPage.MainImage, Global.ContentAreaTags.OneThirdWidth)" />
Default media format: image = 50034, video = 50040
e.g. <img src="@Url.GetMediaUrl(Model.CurrentPage, x => Model.CurrentPage.ImageFormatBig)" />
Priority to get specific media format
Through the MediaFormat pass as parameter to extension
Through the MediaFormat attribute on the content model
Through tagmapping pass as parameter to extension (in our example case, there is a rule set up in initialization that if the rendering tag is "span4" then it should use mediaformat small for images)
If nothing is defined we fall back to the default mediaformat (which should be configurable - and can vary based on file type)
As site developer we can get media url via content reference extension where the format return base on name, id or tagging
public static string DigizuiteMediaUrl(this ContentReference contentReference, object additionalParam = null)
e.g.
var tag = ControllerContext.ParentActionViewContext.ViewData["tag"] as string;
string ub = currentContent.ContentLink.DigizuiteMediaUrl(tag);
ContentReference extension
...
Likewise, you might need to find a specific cropped version on an asset in code, and using this code you can do just that:
public static ContentReference GetCrop(this ContentReference contentReference, string cropName)
e.g. <img src="@Url.ContentUrl(Model.CurrentPage.ImageFormatSmall.GetCrop("banner"))" />
Combine get crop and media format by Name, Id or a tagging
e.g. <img src="@Model.CurrentPage.ImageFormatSmall.GetCrop("square").DigizuiteMediaUrl("Small")" />
e.g. <img src="@Model.CurrentPage.ImageFormatSmall.GetCrop("square").DigizuiteMediaUrl(50036)" />