A formatter that renders the video URL can be useful for passing to theme templates, indexing, or admin views.
| Comment | File | Size | Author |
|---|---|---|---|
| #18 | video_embed_field-url-formatter-2879932-18.patch | 1.5 KB | peacog |
| #18 | interdiff-2879932-6-18.txt | 735 bytes | peacog |
| #6 | video_embed_field-url-formatter-2879932-6.patch | 1.26 KB | brunodbo |
| #2 | video_embed_field-url-formatter-2879932-2.patch | 1.63 KB | recrit |
Issue fork video_embed_field-2879932
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #2
recrit commentedThe attached patch adds a field formatter video_embed_field_video_url.
Comment #3
sam152 commentedDo we need to extend this?
Why is this relevant?
Why not just print $item->value? We cannot rely on #url being set, some providers might choose to return a different render array structure to render their videos.
I don't think this is needed.
Comment #4
recrit commented@Sam152:
1 - This was extended in order to get the render code from the plugin.
2 - Autoplay - To allow the plugin to return a url with the proper structure for autoplaying, Example: "?autoplay=1".
3 - The entered value != the url. The plugins extract the id and then create a url in their embed code.
4 - Needed for #2.
An alternative approach could be to add a method to the plugin interface for "getUrl()". Then this url formatter could use that to get the url.
Comment #5
sam152 commentedRe: #3, what I'm saying is, the method is called renderEmbedCode, it doesn't enforce across all the providers who implement the interface that the renderable array returned will by type => video_embed_iframe, this is simply a convention the youtube/vimeo ones use currently.
Comment #6
brunodboThe patch in #2 was outputting an incorrect url for me (
https://www.youtube.com/embed/videoseries), without the video ID.Attached patch simply outputs the
$item->value, as suggested in #3, which I would expect from a 'Video URL' field formatter. Not sure if this a solid approach though (we may need to build the url in a different way).Comment #7
sam152 commentedStill NW for tests.
Comment #8
anybody+1 for this, very important requirement!
Comment #9
krisrobinson commented+1 for this, could it also be used to provide the thumbnail URL instead of the thumbnail image?
Comment #10
GenkiOne commentedIs this issue still alive ?
Because it would be very useful
Comment #11
anybody-- Comment was incorrect sorry -- *deleted*
Comment #12
gijimmyj commented+1 for this as well. It seems likely that you would want to get at the video url
Comment #13
anybody@brunodbo, would you be so kind to reroll your patch and check why the tests fail? It would be nice to have this RTBC'd soon.
Comment #14
ConradFlashback commented+1
Comment #15
brunodboQueuing test bot.
Comment #16
brunodboIs the test that failed in #6 still relevant? It doesn't show up at https://www.drupal.org/node/1243930/qa anymore. In any case, I queued the patch in #6 for testing with the 'PHP 5.5 & MySQL 5.5, Drupal 8.7.x' test.
As far as I can tell from https://www.drupal.org/pift-ci-job/819115, the fail in #6 had to do with the usage of deprecated code elsewhere in the module, not related to the patch.
Comment #17
anybodyWell I think we can set this RTBC? patch is green now and we have good feedback!
Comment #18
peacog commentedThank you very much for this patch. I've made a small modification to it to better support Youtube playlists. When the provider is a playlist, the url should link to the playlist page rather than to the first video in the playlist. This patch achieves that by simply changing the url from
youtube.com/watchtoyoutube.com/playlist.Comment #19
anybodyThank you Peacog,
your patch looks good and works, but I can't get that str_replace, which seems a bit dirty to me. Can you provide a working example here? If I change watch to "playlist" in Youtube URLs, the URL is broken for me? What am I doing wrong?
Would be nice to push this forward!
Comment #20
anybodyHi @Peacog,
could you perhaps provide a short example for my "str_replace" question in #18? It would be nice to move forward here, because this is a deserved feature for several users.
Comment #21
peacog commentedHi @Anybody.
When you want to embed a playlist this module requires you to provide an url with the format https://www.youtube.com/watch?v=VIDEO_ID&list=PLAYLIST_ID, i.e. it includes the id of the first video as well as the id of the playlist itself. With urls of that format you can replace 'watch' with 'playlist'.
There is an alternative way to solve the playlist problem in #3028911: Provider does not support linking to playlist page. I haven't tried it myself but if it works it might be a better solution.
Comment #22
recrit commentedComment #23
anybodyWell I think we can set this RTBC now and hope for maintainer review?
Comment #24
sam152 commentedWith the advent of Media in core, the Video Embed Field module has moved to being minimally maintained. Only issues which assist in the migration to Media in core will be committed. To read more about this decision, please see: #3089599: Maintenance status for Video Embed Field now that media is in core.
Comment #25
anybodyI'd like to set this back to RTBC as this now has a 3.0.x branch, this still works perfectly and patch still applies. Can we please merge this into 3.0.x?
Comment #26
mably commentedCould we have an MR please?
Comment #27
anybody@mably thanks for the super quick reply! Yes already on it, we'll post it here tomorrow! Probably @grevil will do it and finally check the implementation.
Comment #30
grevil commentedOk, I created the MR and made the code a bit prettier. Please review!
I am a bit unsure about the output array:
looks a bit odd don't you think?
Comment #31
grevil commentedNote, that test failures are unrelated. The tests are simply not compatible with the newest PHPUnit version. We should fix that in a seperate issue.
Comment #32
anybodyRe #30 that was already part of the first patch and has been reviewed, so I think it should be fine IMHO
Please link the test issue here, once created.
Comment #33
grevil commentedDone, tests fixed here: #3554816: Fix PHPUnit tests.
Comment #34
mably commentedRelated issue has been merged.
Comment #35
anybodyTests are also green here now! :)
Comment #37
mably commented