Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/airesvsg/acf-youtubepicker

Search and select videos on YouTube without leaving the page.
https://github.com/airesvsg/acf-youtubepicker

Last synced: about 1 month ago
JSON representation

Search and select videos on YouTube without leaving the page.

Awesome Lists containing this project

README

        

ACF YouTube Picker Field
================
Search and select videos on YouTube without leaving the page.

![ACF YouTube Picker Field](http://www.airesgoncalves.com.br/youtubepicker/acf-youtubepicker-v3.png)

- [Compatibility](#compatibility)
- [Installation](#installation)
- [Retrieving data](#retrieving-data)
- [Retrieving data - Single](#single)
- [Retrieving data - Multiple](#multiple)

Compatibility
================
This ACF field type is compatible with:
* ACF 5
* ACF 4

Installation
================
1. Copy the `acf-youtubepicker` folder into your `wp-content/plugins` folder
2. Activate the `YouTube Picker` plugin via the plugins admin page
3. Create a new field via ACF and select the `YouTube Picker` type

Retrieving data
================

#### Single
```php
// how to display data
$video = get_field( 'youtube_single_video' );

if( $video ) {
echo '

' . $video['title'] . '

';
echo '';
}
```

```php
$video = get_field('youtube_single_video');

print_r( $video );

// Output
Array
(
[title] => Rio 2016
[vid] => Z00jjc-WtZI
[url] => https://www.youtube.com/watch?v=Z00jjc-WtZI
[duration] => 00:02:23
[thumbs] => Array
(
[default] => Array
(
[url] => https://i1.ytimg.com/vi/Z00jjc-WtZI/default.jpg
[width] => 120
[height] => 90
)

[medium] => Array
(
[url] => https://i1.ytimg.com/vi/Z00jjc-WtZI/mqdefault.jpg
[width] => 320
[height] => 180
)

[high] => Array
(
[url] => https://i1.ytimg.com/vi/Z00jjc-WtZI/hqdefault.jpg
[width] => 480
[height] => 360
)

[standard] => Array
(
[url] => https://i1.ytimg.com/vi/Z00jjc-WtZI/sddefault.jpg
[width] => 640
[height] => 480
)

[maximum] => Array
(
[url] => https://i1.ytimg.com/vi/Z00jjc-WtZI/maxresdefault.jpg
[width] => 640
[height] => 480
)

)
[iframe] =>
)
```

#### Multiple
```php
// how to display data
$videos = get_field( 'youtube_multiple_videos' );

if( $videos ) {
foreach( $videos as $v ) {
echo '

' . $v['title'] . '

';
echo '';
}
}
```

```php
$videos = get_field('youtube_multiple_videos');

print_r( $videos );

// Output
Array
(
[0] => Array
(
[title] => Rio 2016
[vid] => Z00jjc-WtZI
[url] => https://www.youtube.com/watch?v=Z00jjc-WtZI
[duration] => 00:02:23
[thumbs] => Array
(
[default] => Array
(
[url] => https://i1.ytimg.com/vi/Z00jjc-WtZI/default.jpg
[width] => 120
[height] => 90
)

[medium] => Array
(
[url] => https://i1.ytimg.com/vi/Z00jjc-WtZI/mqdefault.jpg
[width] => 320
[height] => 180
)

[high] => Array
(
[url] => https://i1.ytimg.com/vi/Z00jjc-WtZI/hqdefault.jpg
[width] => 480
[height] => 360
)

[standard] => Array
(
[url] => https://i1.ytimg.com/vi/Z00jjc-WtZI/sddefault.jpg
[width] => 640
[height] => 480
)

[maximum] => Array
(
[url] => https://i1.ytimg.com/vi/Z00jjc-WtZI/maxresdefault.jpg
[width] => 640
[height] => 480
)

)
[iframe] =>
)
)
```