Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature] Input Youtube/Vimeo Field #130

Merged
merged 6 commits into from
Oct 17, 2016
Merged

[Feature] Input Youtube/Vimeo Field #130

merged 6 commits into from
Oct 17, 2016

Conversation

OwenMelbz
Copy link
Contributor

@OwenMelbz OwenMelbz commented Sep 22, 2016

summary
Enables users to save youtube or vimeo videos to fields with useful basic meta data attached

preview
backpack- video field type 2

usage

database column type should be either json or text

protected $casts = [‘video’ => ‘array’];

$this->crud->addField([
'label' => ‘YouTube / Vimeo video’,
'type' => 'video',
'name' => ‘video’
]);

$this->crud->setColumnDetails(‘video’, ['type' => 'video']);

this will return an object similar to

$video = {
    id: 234324,
    title: ‘my video title’,
    image: ‘https://provider.com/image.jpg',
    url: ‘http://provider.com/video',
    provider: ‘youtube’
}

I had a look around for the video detector library, I found a few that
were overly bloated or didnt work with the latest youtube api, so I
opted for a simple bespoke one

usage

database column type should be either json or text

```
protected $casts = [‘video’ => ‘array’];

$this->crud->addField([
            'label' => ‘YouTube / Vimeo video’,
            'type' => 'video',
            'name' => ‘video’
        ]);

$this->crud->setColumnDetails(‘video’, ['type' => 'video']);

```

this will return an object similar to

$video = {
    id: 234324,
    title: ‘my video title’,
    image: ‘https://provider.com/image.jpg',
    url: ‘http://provider.com/video',
    provider: ‘youtube’
}
@tabacitu
Copy link
Member

Awesome! Will check and merge this weekend. Great job!

@tabacitu
Copy link
Member

Tested, it works for both normal URLs and "share this" URLs, which is great.

Two mentions though:

  1. If a user edits an entry, pastes the code and then clicks "Save" (without clicking outside the video input first) the value won't be stored, because there was no time to get the info and place it in the hidden input. We should try parseVideoLink() on paste/keypress/change/something else to avoid this.
  2. I think we should put both the input and the preview on one line. Either using a suffix or just side-by-side. That way it takes up less space.

Cheers!

@OwenMelbz
Copy link
Contributor Author

@tabacitu just pushed the above 2 changes, give them a look when you can :)

@OwenMelbz
Copy link
Contributor Author

@tabacitu have updated incase you want to check it out

@OwenMelbz OwenMelbz changed the title added youtube/vimeo field [Feature] Input Youtube/Vimeo Field Oct 4, 2016
@OwenMelbz OwenMelbz removed the ready label Oct 4, 2016
@tabacitu
Copy link
Member

tabacitu commented Oct 7, 2016

Hi @OwenMelbz ,

I think it looks and works great. It's one-line, we can use it with col-md-4 or col-md-6, looks simple and is intuitive. Great work. Also, tried the column - looks and works great. No comments there. Pushed an update to make them both work with and without attribute casting.

...sorry to come back to you with this. But I got this bug that... well, it keeps bugging me :-) It seems to me like the video name shows up for a split second on screen when hovering the screenshot. Might only be happening on Youtube. I used this link: https://www.youtube.com/watch?v=sqiyXwFig-8
backpack video field small bug

Could you take a look when you have the time, maybe you figure it out?

Cheers!

@OwenMelbz
Copy link
Contributor Author

@tabacitu ha wow that's a funky bug! Wonder how I missed that lol! I'll have to check it next week as away with family this weekend with only my phone!

@tabacitu
Copy link
Member

Sure, no rush :-) Enjoy family time. I'll keep replying to your emails and issues though - please ignore them until you're back.

@OwenMelbz
Copy link
Contributor Author

Oh the fun is over already haha! Been back at work last 2 days, so back in full swing, will give this a look over tonight hopefuly

@OwenMelbz
Copy link
Contributor Author

@tabacitu i cant actually replicate this, but are you able to pull the branch and see if its still happening please?

thanks

@tabacitu
Copy link
Member

Yup, it's now fixed, thank you. Merging!

@tabacitu tabacitu merged commit 84332b3 into master Oct 17, 2016
@tabacitu tabacitu deleted the video-field branch October 17, 2016 14:28
This was referenced Apr 2, 2020
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