x2_many_media_viewer
The Add Media gallery on eCommerce products is a one2many wearing a media manager. x2_many_media_viewer swaps the usual Add row for Odoo's image and video dialog, and can transcode every upload to WebP.
| Technical name | x2_many_media_viewer |
|---|---|
| Field types | one2many, many2many |
| Views | form (kanban sub-view) |
| Module | html_editor, auto-installed with the editor |
| Used in core | 2 occurrences in website_sale: template and variant Extra Media galleries |
| Versions | Odoo 20.0, Odoo 19.0, Odoo 18.0 |
| No-code setup | No. Applied in view XML on a one2many of image records |
| Alternatives | one2many, many2many_binary, image |
What the media viewer field does
What this means for your team
Supported options in Odoo 19
| Option | Type | What it does |
|---|---|---|
convert_to_webp | boolean (undocumented) | Transcodes every picked image (except GIF and SVG) to WebP and generates resized WebP plus JPEG attachments at 1024, 512, 256 and 128. Read only in extractProps; absent from the declared option list. Core enables it on both eCommerce galleries.(since Odoo 18.0) |
create / delete / link / unlink | boolean or domain (inherited) | The standard x2many crud gates are inherited unchanged from the base descriptor and still control the embedded kanban's abilities. |
The target model's field names are a contract. Videos require a video_url char field and images require the image_1920 family in the sub-view; records land with whatever subset exists there. Core's product.image model is shaped exactly for this. Point the widget at a one2many of anything else and picks either drop data or create half-empty lines.
Working examples
Inside the WebP pipeline and the URL-attachment trap
Version compatibility
| Version | Status | Notes |
|---|---|---|
| Odoo 20.0 | In development | Not released. New options, auto-loaded fields and video thumbnails on the development branch. See below. |
| Odoo 19.0 | Verified | File moved into html_editor's fields folder; WebP export uses default quality. |
| Odoo 18.0 | Verified | Introduced with html_editor; WebP exported at quality 0.75. |
| Odoo 17.0 | Not available | Widget does not exist; galleries were plain x2many kanbans. |
| Odoo 16.0 | Not available | Widget does not exist. |
Upgrade note. Moving from 18 to 19 requires no XML changes; the file moved inside html_editor and the media dialog API swapped its tab flags, both invisible to views. Custom patches on the 18 file path need their import updated.
What is changing in Odoo 20
Common problems and fixes
| Symptom | Cause and fix |
|---|---|
| Cannot add URL type attachment warning | The picked attachment stores a URL, not binary data; the widget only consumes binary attachments. Re-upload the image file so a binary attachment exists, then pick again. |
| Video pick creates a line but the site shows nothing | The target model lacks a video_url field, or the URL platform was not recognized. Mirror product.image's video_url field and paste a standard YouTube or Vimeo link. |
| Images upload but stay JPEG or PNG | convert_to_webp is not passed in the view's options; the widget does not default it on. Add options="{'convert_to_webp': True}" like the core product views. |
| GIF or SVG did not convert to WebP | Both formats are deliberately excluded from the pipeline to preserve animation and vectors. Expected behavior; convert externally if you need stills. |
| Multi-pick added only some of the images | The loop stops at the first URL-type attachment it hits, abandoning the rest of the batch. Fix or drop the offending attachment and re-pick the remainder. |
| Gallery renders below the buttons instead of above | A custom template override lost the widget's renderer relocation. Keep the html_editor.X2ManyMediaViewer template inheritance intact. |
Media viewer field vs the alternatives
| Widget | Best for | Key difference |
|---|---|---|
x2_many_media_viewer | Gallery one2manys where picks come from the media dialog: product images and videos | Replaces the x2many Add flow with the media dialog and an optional WebP transcode pipeline |
| one2many | Ordinary embedded lists and kanbans of child records | Add creates an empty row or opens a form dialog; no media dialog, no transcoding |
| many2many_binary | Attaching multiple files to a record without a gallery model | Writes ir.attachment links directly; no image fields, no video URLs |
| image | One image stored on the record itself | Single binary field with its own upload and WebP option, no collection semantics |
Frequently asked questions
Which video platforms work in the Videos tab?+
Why does every image create several attachments?+
Can I use the widget on my own model?+
Does the widget resize the images it stores on the record?+
Is x2_many_media_viewer available in Odoo 17?+
Product pages heavy, galleries painful to maintain?
Media pipelines decide storefront speed. We tune Odoo eCommerce catalogs end to end, WebP galleries, variant media, CDN and Core Web Vitals, so your product pages load fast and your team stops fighting the back office.
Book a free consultation