backdrop-contrib / youtube

Easily embed YouTube videos in your Backdrop CMS website
https://backdropcms.org/project/youtube
GNU General Public License v2.0
2 stars 4 forks source link

Preserve start at time from URL #30

Closed yorkshire-pudding closed 11 months ago

yorkshire-pudding commented 11 months ago

Story As a site editor I want to set an embedded video to start at a particular time So that users can easily find the part of the video I'm referencing

Acceptance criteria Given that a URL has a start time embedded in it (e.g. &t=2373 which refers to 39:33) When the video is embedded in a page Then the video will start at that time (i.e. it will include start=2373 in the query).

Note - I gave this a little test by hacking the module output to include this in the query parameters (i.e. $query['start'] = '2373'; within theme_youtube_video) and it worked but I'm not sure how best to add this into the module.

It could be that simply adding a backdrop_alter() to the $query array could allow a custom module to insert this? I note that the t value is saved in the database as part of the field value in field_name_input

@jenlampton - any ideas?

jenlampton commented 11 months ago

yes, all we need to do is split the query off the value stored in the database, and then add it on as $query, just as you've done. See https://docs.backdropcms.org/api/backdrop/core%21includes%21common.inc/function/backdrop_parse_url/1

yorkshire-pudding commented 11 months ago

Thanks @jenlampton - I've added a PR that adds this feature in

yorkshire-pudding commented 11 months ago

@jenlampton - it won't be possible to merge #32 and #36 consecutively. Whichever one is first, I'll need to rebase the other before that gets merged as they affect a similar area

jenlampton commented 11 months ago

I've merged #32, so #36 will need to be rebased.