Did you noticed that images relation is available directly in nodeSource object? That’s a little shortcut to
(nodeSource|handler).documentFromFieldName('images'). Cool, isn’t it? When you create your documents field in your
node-type, Roadiz generate a shortcut method for each document relation in your GeneratedNodesSources/NSxxxx class.

Now, you can use the DocumentViewer service to generate HTML view for your documents no matter they are images, videos or embed. Two Twig filters are available with Documents:

|display generates an HTML tag to display your document.

|url generates a public URL to reach your document.

|embedFinder gets the EmbedFinder for current document according to the embed-platform type (Youtube, Vimeo, Soundcloud…).

{# Grab only first document from “images” field #}{%setimage=nodeSource.images[0]%}{# Always test if document exists #}{%ifimage%}{{image|display({'width':200,'height':200,'crop':"1:1",'quality':75,'embed':true})}}{%endif%}

You can use multiple source files for one video document or audio document.
Just upload a file using tge same filename name but with a different extension. Use this method to
add a poster image to your video too.
For example: for my-video.mp4 file, upload my-video.webm, my-video.ogg
and my-video.jpeg documents. Roadiz will automatically generate a <video> tag using all these files as source and
poster attribute.

If document is an image: getDocumentByArray method will generate an <img/> tag with a src and alt attributes.

If it’s a video, it will generate a <video/> tag with as many sources as available in your document database. Roadiz will look for same filename with each HTML5 video extensions (filename.mp4, filename.ogv, filename.webm).

Then if document is an external media and if you set the embed flag to true, it will generate an iframe according to its platform implementation (Youtube, Vimeo, Soundcloud).

Get the external document URI (the one used for creating iframe for example) with (document|embedFinder).source twig command.

You can store documents inside settings for global images such as header images or website logo.
Simply create a new setting in Roadiz back-office choosing Document type, then a file selector will appear in settings list to upload your picture.

To use this document setting in your theme, you can assign it globally in your MyThemeApp::extendAssignation method.
Use getDocument method instead of get to fetch a Document object that you’ll be able to display in
your Twig templates:

This way is the easiest to fetch a global document, but it needs you to upload it once in Settings section.
If this does not suit you, you can always fetch a Document manually using its Doctrine repository and a hard-coded filename.