Skip to content

Improve MediaWebPart modernization mappings - #1307

Merged
YifengMao merged 4 commits into
devfrom
yifengmao-media-web-part-mapping
Oct 30, 2026
Merged

YifengMao merged 4 commits into
devfrom
yifengmao-media-web-part-mapping

Conversation

@YifengMao

@YifengMao YifengMao commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • Resolve MediaWebPart configuration before selecting a mapping, including source-page context and VideoSet encoding/embed precedence.
  • Map validated HTTPS iframe content to the public Embed component without trusted cached markup. Keep native HTML Field Security and framing checks in effect.
  • Run asset handling and strict file lookup only in the selected File and Media branch; preserve the actual owning site, web, list, file IDs and URLs for same-site and cross-site conversion.
  • Warn and skip missing, unsupported or placeholder media rather than emitting an empty file component. Leave shared DocumentEmbedLookup behavior and the global function pipeline unchanged.
  • Keep the mapping entry points short in BuiltIn.cs, with media implementation in MediaWebPartMapping.cs and shared encoding/URL helpers in FunctionsBase. Update only the Media sections in both mapping XML copies.

Validation

  • 47 focused tests passed (15 Media cases plus 32 existing regressions): mapping selection/order, safe encoding, VideoSet/context resolution, invalid inputs, transferred/retained file identities, and existing DocumentEmbed/slideshow/Page Viewer regressions.
  • dotnet build .\src\lib\PnP.Framework\PnP.Framework.csproj -f net8.0 --no-restore passed.
  • Ran public ConvertTo-PnPPage with explicit mapping/connection and isolated, hash-verified rebuilt Framework binaries. Read back saved controls and compared their identities to the actual files.
  • Playwright confirmed real Embed playback and same-site/cross-site MP4 playback through completion, with no media-element errors.
  • All run-owned tenant fixtures were removed; cleanup queries confirmed zero remaining test artifacts.

Scope and limitations

  • Uses only the existing public Embed and File and Media components.
  • Classic autoplay, loop, preview images and rendition switching are not preserved. VideoSet rendition-item URLs and rendition-only fallback are not added.
  • Existing asset-transfer support is unchanged. If a valid file remains at its source, its source URL and identities are retained with an explicit access warning.
  • Destination Embed policy is checked by the native component at render time; cached markup does not bypass it.

yifengmao and others added 3 commits October 28, 2026 13:48
Validate iframe media without trusted embed caches, and resolve file identities only in the selected File and Media branch.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Keep the existing BuiltIn mapping API and media behavior unchanged while separating media-specific helpers from BuiltIn.cs.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Replace the partial-class split with an internal MediaWebPartMapping helper, retain short public mapping functions in BuiltIn, and share JSON/URL utilities through FunctionsBase.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@YifengMao

Copy link
Copy Markdown
Contributor Author

Playback screenshots

Player-only crops from the browser verification; tenant/account details are excluded and fixture filenames are redacted. These were captured before the behavior-preserving helper extraction. Playback was rechecked successfully on the final PR commit.

Embed

The migrated Embed component rendered the video, and Playwright confirmed playback time advancing without a media error.

Migrated Embed displaying a video frame

Video frame: Big Buck Bunny, (c) copyright 2008, Blender Foundation / www.bigbuckbunny.org, CC BY 3.0. Screenshot cropped to the player.

File and Media: same-site conversion

The generated one-second MP4 played to completion. The native player shows Replay and 0:01 / 0:01.

Same-site File and Media player after successful playback

File and Media: cross-site conversion

The copied destination MP4 also played to completion, with the destination file identities verified separately.

Cross-site File and Media player after successful playback

All run-owned test pages, videos, and copied asset folders were cleaned up after verification.

Reduce repetitive VideoSet cases and lower-priority validation variations while retaining mapping order, unsafe embed, missing media, and cross-site identity coverage.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@YifengMao
YifengMao merged commit 504ab61 into dev Oct 30, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants