Skip to content

feat: image and video blocks - #3638

Open
global-prog wants to merge 8 commits into
nextcloud:mainfrom
global-prog:contrib/media-blocks
Open

global-prog wants to merge 8 commits into
nextcloud:mainfrom
global-prog:contrib/media-blocks

Conversation

@global-prog

@global-prog global-prog commented Sep 9, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Adds two display-only blocks, Image and Video, so a form can show a picture or a video between its questions instead of only text.

They are ordinary question types that carry no answer, so they reuse the existing ordering, drag and drop and jumps ("After question N") without new concepts. A shared ANSWER_TYPES_DISPLAY_ONLY list marks them: submission validation refuses an answer to them and exports leave them out, so they add no empty CSV column.

What a block can show

Address Result
Image or video shared publicly from this Nextcloud Shown inline; videos use the browser's own player
YouTube or Vimeo video Placeholder naming the provider and what playing discloses; the player loads only after Play video
Image on another site Not shown (blocked by Nextcloud's content security policy); the editor says so
Any other video address Shown as a link

The address field explains this in its hint, and every block can carry a description for screen readers (images) or a link text (videos).

Privacy

Embedding a player directly would make every respondent's browser contact the video host on page load, disclosing their IP address and usually setting cookies — on an anonymous form that quietly breaks the promise made to respondents. So the player loads only after consent, from youtube-nocookie.com or with Vimeo's do-not-track flag. The pages showing a form (app, public link, embed) allow just these two player origins as frames; nothing changes elsewhere on the server.

Scope

  • No schema change: address, text and jump live in the existing extraSettings.
  • openapi.json is unaffected; FormsQuestionType is left alone, as for linearscale, ranking and color.

🖼️ Screenshots

Desktop

Editor Submit view
Editor with an image and a video shared from Nextcloud, an image on another site with its warning, and a YouTube block waiting for consent that jumps to the end of the form Submit view with the shared image, the shared video in the browser's player and the YouTube consent placeholder

Mobile, 320 px wide (reflow per WCAG 1.4.10 / BITV 2.0; no horizontal scrolling)

Editor Submit view
Editor at 320 pixels wide with all blocks reflowed to one column Submit view at 320 pixels wide with the consent notice fully visible

How to test

  1. Share an image and a video publicly from Files.
  2. Create a form, add an Image and a Video block and paste the share links; add a second video block with a YouTube link.
  3. Open View and the public share link: the shared image and video show inline, the YouTube block shows the consent notice and loads nothing from YouTube until Play video is clicked (check the network tab).
  4. Set "After question N" on a block and check that the skipped question is hidden.
  5. Submit the form and export the responses: the blocks have no column.

Automated tests

  • SubmissionServiceTest: validation refuses answers to the blocks, exports skip them.
  • FormsServiceTest: their extraSettings, including the jump, are accepted.
  • PageControllerTest: every page showing a form allows the two player origins as frames.
  • tests/fixtures/jump-paths.json: jumps on image and video blocks, checked on the server and in the browser.
  • playwright/e2e/media-blocks.spec.ts: shared images and videos shown inline; external image flagged and not rendered; hints announced with the address field; non-video file falls back to the link; YouTube (watch?v=, youtu.be, shorts) and Vimeo load only after consent with no request before; other video addresses stay a link; consent notice fits at 320 px; a jump on a block skips the question in between; a form with both blocks can be submitted.

🤖 AI (if applicable)

  • The content of this PR was partly or fully generated using AI

@Chartman123

Copy link
Copy Markdown
Collaborator

@global-prog Please look at the corresponding issue at #624 to see if you covered all of what has been discussed there already. Also please add the AI declaration to your description if you used AI for this.

@Chartman123 Chartman123 added this to the 5.5 milestone Sep 11, 2026
@Chartman123 Chartman123 linked an issue Sep 11, 2026 that may be closed by this pull request
@codecov

codecov Bot commented Sep 11, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 88.46154% with 3 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
lib/Controller/PageController.php 75.00% 3 Missing ⚠️

📢 Thoughts on this report? Let us know!

@global-prog

Copy link
Copy Markdown
Contributor Author

Thanks, I read through #624.

It is mostly about section headings and descriptions to break up a long form, which this PR does not do: it only adds image and video blocks. So I don't think it should close #624 on its own. Section headings are what #2913 is working on.

One thing that may help there: this PR adds a shared ANSWER_TYPES_DISPLAY_ONLY list in Constants, which SubmissionService checks during validation and when building the export. I've also added the backend check you asked for on #2913: an answer submitted to a display-only block is now refused rather than skipped, with tests. If sections land as a question type they could go on the same list and get that behaviour without a second mechanism.

If you decide display content shouldn't be a question type, which is the open question on #2913, I'll follow that decision here too.

The AI declaration is added to the description.

@github-actions

Copy link
Copy Markdown
Contributor

Hello there,
Thank you so much for taking the time and effort to create a pull request to our Nextcloud project.

We hope that the review process is going smooth and is helpful for you. We want to ensure your pull request is reviewed to your satisfaction. If you have a moment, our community management team would very much appreciate your feedback on your experience with this PR review process.

Your feedback is valuable to us as we continuously strive to improve our community developer experience. Please take a moment to complete our short survey by clicking on the following link: https://cloud.nextcloud.com/apps/forms/s/i9Ago4EQRZ7TWxjfmeEpPkf6

Thank you for contributing to Nextcloud and we hope to hear from you soon!

(If you believe you should not receive this message, you can add yourself to the blocklist.)

@Koc

Koc commented Oct 7, 2026 •

Copy link
Copy Markdown
Contributor

Hey @global-prog! Thank you for work on it. Few notes from my side:

  1. I didn't get how can I insert already existent uploaded file? Would be nice to add a file picker + share this file in case if we share form?

  2. video not works for me, I had an attempt to add https://www.w3schools.com/tags/mov_bbb.mp4 but there is no video player. Can we add a viewer integration like in a collectives?

image

@Koc

Koc commented Oct 8, 2026

Copy link
Copy Markdown
Contributor

BTW why can't we just embedd images/video into question description (as it already supports markdown)?

@Chartman123 Chartman123 added the stale On hold label Oct 30, 2026
@Chartman123 Chartman123 modified the milestones: 5.5, 5.6 Nov 20, 2026
@AndyScherzinger
AndyScherzinger force-pushed the contrib/media-blocks branch 2 times, most recently from f381500 to 5e8ec20 Compare November 27, 2026 14:34
@AndyScherzinger

Copy link
Copy Markdown
Member

BTW why can't we just embedd images/video into question description (as it already supports markdown)?

Because of CORS / same origin. Markdown in the sense of Collectives, just stores the images next to the markdown in Nextcloud files. So a simple start is what this PR does, relying on public shares and than you are fine, or even internal shares that just work for the people who it has been shared with. Tables has the same concept now. You can add images in a column, but only people with read permissions can see it.

Not optimal, but a start

@AndyScherzinger
AndyScherzinger force-pushed the contrib/media-blocks branch 3 times, most recently from c727a38 to cfb2c14 Compare December 1, 2026 17:42
@AndyScherzinger AndyScherzinger added 3. to review Waiting for reviews and removed 2. developing Work in progress stale On hold labels Dec 1, 2026
@AndyScherzinger AndyScherzinger modified the milestones: 6.1, 6.0 Dec 1, 2026
@AndyScherzinger
AndyScherzinger force-pushed the contrib/media-blocks branch 2 times, most recently from edd7780 to b034503 Compare December 1, 2026 19:04
global-prog and others added 8 commits December 2, 2026 09:53
Adds two display-only blocks so a form can show a picture or point at a video
between its questions, rather than only text.

They are modelled as ordinary question types that happen to carry no answer, which
keeps them in the existing ordering and drag-and-drop with no new concepts. A shared
ANSWER_TYPES_DISPLAY_ONLY list marks them so they are skipped when validating a
submission and filtered out of exports - without that, each block would add an empty
column to every CSV.

Video is deliberately NOT embedded in an iframe. Embedding makes every respondent's
browser contact the video host on page load, disclosing their IP address and usually
setting cookies, which would quietly undermine a form marked as anonymous. It renders
as a link the respondent chooses to follow.

Images do render inline, since that is the point of an image block, but with
referrerpolicy="no-referrer" so the form's address is not passed on, and the editor
warns when the address is not on this instance.

No schema change: the address and description live in the existing extraSettings.
FormsQuestionType is left alone, matching how linearscale, ranking and color are
already handled, so openapi.json is unaffected.

Signed-off-by: global-prog <raqeeb@uosamarra.edu.iq>
A display-only block was skipped during validation whether or not an answer came with it,
so a hand-made request could store an answer against a block that has nowhere to show
it. An absent answer is still expected -- and still must not count as a missing required
one -- but a present answer is now refused.

The submit view never sends one for these blocks, since they emit no value, so this
changes nothing for a form filled in normally.

Adds tests for both halves, and for the image and video settings accepted by
areExtraSettingsValid, which were not exercised before.

Signed-off-by: global-prog <raqeeb@uosamarra.edu.iq>
A video block was only a link. For YouTube and Vimeo addresses it now
shows a placeholder that names the provider and explains that playing
the video discloses the viewer's IP address and may set cookies. The
player loads only after the viewer clicks "Play video", from
youtube-nocookie.com or with Vimeo's do-not-track flag. The link stays
below it, and other addresses keep the plain link. The pages showing a
form allow these two player origins as frames.

Images on another site never loaded, because the content security
policy only allows images from the instance. The editor now says that
only images stored on this Nextcloud can be shown, and neither view
renders a broken image any more. The warning about external
addresses is gone, as nothing is loaded from them.

The block's fields now line up with the title field in the editor, and
the image and link align to the start like the other question content.
The link is underlined so it reads as a link.

Assisted-by: ClaudeCode:claude-opus-5-5
Signed-off-by: Andy Scherzinger <info@andy-scherzinger.de>
The submit view validates every question component before sending
and stops when one has no validate function, so a form containing an
image or video block showed "Some answers are not valid" and could not
be submitted. Display-only blocks take no answer and are always valid.

Assisted-by: ClaudeCode:claude-opus-5-5
Signed-off-by: Andy Scherzinger <info@andy-scherzinger.de>
End-to-end tests check that an image on this instance is shown, that
an image on another site is flagged in the editor and not rendered,
that YouTube and Vimeo players only load after the respondent clicks
"Play video", that other video addresses stay a plain link, and that a
form with both blocks can be submitted. A unit test checks that the
blocks are left out of the export.

Assisted-by: ClaudeCode:claude-opus-5-5
Signed-off-by: Andy Scherzinger <info@andy-scherzinger.de>
The link of a public share opens the share page, not the file, so an
image block given that link showed nothing. Such links are now turned
into the share's download address when the block is shown; the stored
address stays as entered.

A video block whose address is on this instance now plays in a native
video player. Nothing leaves the instance, so it needs no consent; it
only preloads the metadata, so opening the form does not download the
video. If the file cannot be played, only the link is shown.

The address field of both blocks now explains which addresses work,
and the error for an image on another site says that only images
shared publicly from this Nextcloud can be shown.

Assisted-by: ClaudeCode:claude-opus-5-5
Signed-off-by: Andy Scherzinger <info@andy-scherzinger.de>
NcTextField now types its value as string or number, so the update
handlers take both and store the value as a string.

Assisted-by: ClaudeCode:claude-opus-5-5
Signed-off-by: Andy Scherzinger <info@andy-scherzinger.de>
Like sections in other form tools, a block that only shows something
can still decide where the form continues, so image and video blocks
offer the same "go to after this question" jump as text questions.

Assisted-by: ClaudeCode:claude-opus-5-5
Signed-off-by: Andy Scherzinger <info@andy-scherzinger.de>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add sections or multiple descriptions

4 participants