Conversation
This was referenced Sep 14, 2026
edalzell
force-pushed
the
feature/video-value-object
branch
from
September 14, 2026 23:10
62b7e0b to
ca149d0
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The
videofieldtype doesn't implementaugment(), so the raw string is all a template ever gets. There's no provider discriminator, and no first-class way to get an embed URL —{{ video_field | embed_url }}works only becauseCoreModifiers::embedUrl()happens to know how to rewrite YouTube and Vimeo URLs by hand.This augments to a
Statamic\Fieldtypes\Video\Videovalue object exposingprovider,id,urlandembed_url, following theArrayableString/ArrayableLinkconvention:__toString()returns the original value, so{{ video_field }}is unchanged, and it implementsArrayable,ArrayAccess,BoolableandJsonSerializable. It recognises YouTube, Vimeo, direct video files (viaFileTypes::video()) andcloudflare:<id>values, falling back to anunsupportedprovider.The YouTube/Vimeo URL→embed logic is moved out of
CoreModifiers::embedUrl()onto the value object, and the modifier now delegates to it — one implementation rather than two.embedUrl,trackableEmbedUrlandisEmbeddablealso accept the object directly. The existing modifier tests pass unchanged, which is the regression proof for the move.Worth a look:
augment()returns the object for all values, including plain URLs.__toString()covers direct output, modifiers and GraphQL (the existing GraphQL test still passes unchanged), but a strictis_string()check downstream would now see an object. Happy to keep plain URLs as strings and only return the object forcloudflare:values if you'd rather not change that surface in a major.Split out of #11871 so the augmentation contract can be settled on its own, ahead of the Cloudflare Stream and oEmbed work. No new dependencies.