diff --git a/content/docs/project/file/contents.lr b/content/docs/project/file/contents.lr index 806b4fbb..a8251b16 100644 --- a/content/docs/project/file/contents.lr +++ b/content/docs/project/file/contents.lr @@ -197,3 +197,15 @@ name = French url_prefix = /fr/ locale = fr ``` + +### `[attachment_types]` +Lektor does some basic attachment type detection based on file extension. This is what powers the `this.attachemnts.images` and `this.attachments.videos` attributes for instance. If the built-in map does not cover your file extension you can extend it or add new attachement types on a project by project basis. + +Example: + +```ini +[attachment_types] +; <.file-ext> = +.gpx = gpx +.ogv = video +``` diff --git a/content/docs/templates/videoops/contents.lr b/content/docs/templates/videoops/contents.lr new file mode 100644 index 00000000..31f58a72 --- /dev/null +++ b/content/docs/templates/videoops/contents.lr @@ -0,0 +1,77 @@ +title: Video Operations +--- +body: + +Just like [images](../imageops/), videos are separate files that are embedded into HTML files. Since they are media files, it's often desirable to read metadata or manipulate them in some way. + +!! Video metadata access is powered by [FFmpeg](https://ffmpeg.org/). In order to use it FFmpeg must be installed on your system and detected by Lektor. If Lektor is unable to find FFmpeg you will see the error message `Unable to locate ffmpeg or ffprobe executable. Is it installed?` in your console output if you try to use functionality that requires it. + +## Accessing videos + +```html+jinja +{% for video in this.attachments.videos %} +
+{% endfor %} +``` + +Just like images you can also access them using `site.get('/myfolder').attachments.videos` or `site.get('/myfolder').attachments.get('examplevideo.mp4')`. Note that not all formats are detected as videos (see [attachments](../../content/attachments/)). If your format is not in the list you may still be able to get it detected as a video by adding it to your [Lektor project file](../../project/file/#[attachment_types]). + + +## Accessing metadata + +Video objects are sub-classes of Attachments but with a few extra properties. + +| Attribute | Description +| - | - +| `width` | Video height in pixels +| `height` | Video height in pixels +| `duration` | Video length as a [`datetime.timedelta`](https://docs.python.org/3/library/datetime.html) instance + +Example: + +```html+jinja +{% set video = this.attachments.videos.first() %} +