Problem/Motivation
Right now we use #type => html_tag, which takes #attributes => src => URL. The problem is URL becomes a single string parameter, so altering and updating the URL query parameters requires some manipulation on that string, which is painful.
Proposed resolution
Write a custom element type for iframes which specifically accepts query parameter as it's own array which can be modified before rendering. It might look something like:
'#type' => 'embed_iframe',
'#url' => 'https://www.youtube.com/embed/fdbFVWupSsw',
'#params' => [
'autoplay' => '1',
'start' => '100',
'rel' => '0',
],
Remaining tasks
Validate the approach and write a patch.
User interface changes
None.
API changes
None.
Data model changes
None.
Comments
Comment #2
sam152 commentedHere is an initial crack. Should only fail the YouTube tests so far.
Sadface about requiring procedural code.
Comment #3
sam152 commentedComment #9
sam152 commentedAdded some tests for the render element and the query string object.
Comment #10
sam152 commentedFixed the field output test.
Comment #21
sam152 commentedCI error?
Comment #27
sam152 commentedWrong docblock maybe?
Comment #28
benjy commentedreturn http_build_query($this->query) ?: '';
Can also use static::class
Shame this object is needed, wonder if a lazy_builder could help here to process the element.
Why not default to empty arrays, same as the element info?
Comment #29
sam152 commented1. Already discussed.
2. I like this better.
3. No idea how this works, will have to look into it.
4. Good point.
Comment #30
sam152 commentedMore feedback.
Comment #31
sam152 commentedComment #33
sam152 commentedThanks for the review!