Git Product home page Git Product logo

acf-youtubepicker's Introduction

ACF YouTube Picker Field

Search and select videos on YouTube without leaving the page.

ACF YouTube Picker Field

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

// how to display data
$video = get_field( 'youtube_single_video' );

if( $video ) {
  echo '<h1>' . $video['title'] . '</h1>';
  echo '<img src="' . $video['thumbs']['default']['url'] . '">';
}
$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] => <iframe src="https://www.youtube.com/embed/Z00jjc-WtZI" width="100%" height="100%" frameborder="0" allowfullscreen></iframe>
)

Multiple

// how to display data
$videos = get_field( 'youtube_multiple_videos' );

if( $videos ) {
  foreach( $videos as $v ) {
    echo '<h1>' . $v['title'] . '</h1>';
    echo '<img src="' . $v['thumbs']['default']['url'] . '">';
  }
}
$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] => <iframe src="https://www.youtube.com/embed/Z00jjc-WtZI" width="100%" height="100%" frameborder="0" allowfullscreen></iframe>
    )
)

acf-youtubepicker's People

Contributors

airesvsg avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

acf-youtubepicker's Issues

HTTP to HTTPS

Hello,

I have an issue with my website which uses HTTPS, the youtube thumbnail is using HTTP.
I got a warning (Mixed Content - the page was loaded over HTTPS, but requested an insecure image - The content should also be served over HTTPS).

Is it possible to change all the URLs in source files from HTTP to HTTPS ?

Thank you !

Incorrect CSS breaks input in non-Webkit browsers

At this moment style definition for YouTube search input field obviously leaves no space for field itself (30px height - 2*15px padding = 0). Webkit seems to handle it differently (and I suppose, incorrectly) then other browsers. In Firefox and IE this style leads to invisible (0px height) input field that is pretty different to use. Correct appearance is achieved by removing height and padding properties from .acf-youtubepicker-field rule.

Additionally, not sure about ACF 4.x, but ACF Pro 5.x defines input style as .acf-input-wrap input and hence requires input field to be wrapped into <div class="acf-input-wrap">.

Conditional selected youtube.picker remains disabled!

For our current project we're' using ACF Pro in combination with ACF YouTube Picker! (love this yt-picker!!!) :)

Workin with the ACF Flexible Content Field, there is a little problem:

There is a layout (export see below) with a selection of media-types -> image or video.
When selecting the option video another selection (radio-buttons) gets visible to select the video-type -> youtube (youtube.picker) or mp4 (post.object).
Click on the mp4.option works fine: the input-field for selecting an media.object appears.
But, when selecting youtube: the field youtube.picker stays disabled! (see snapshot enclosed!)

Thank you,
Kosta

`'layout_5bd038cee6546' => array(
	'key' => 'layout_5bd038cee6546',
	'name' => 'media_large',
	'label' => 'Media (groß)',
	'display' => 'block',
	'sub_fields' => array(
		array(
			'key' => 'field_5bd038fae6547',
			'label' => 'Überschrift (H2)',
			'name' => 'media_large_title',
			'type' => 'text',
			'instructions' => 'Modul- oder Bereichs-Überschrift',
			'required' => 0,
			'conditional_logic' => 0,
			'wrapper' => array(
				'width' => '',
				'class' => '',
				'id' => '',
			),
			'default_value' => '',
			'placeholder' => '',
			'prepend' => '',
			'append' => '',
			'maxlength' => '',
		),
		array(
			'key' => 'field_5beebf6eb6f67',
			'label' => 'Medien-Typ',
			'name' => 'media_large_media_type',
			'type' => 'radio',
			'instructions' => '',
			'required' => 0,
			'conditional_logic' => 0,
			'wrapper' => array(
				'width' => '',
				'class' => '',
				'id' => '',
			),
			'choices' => array(
				'mlmt_image' => 'Bild',
				'mlmt_video' => 'Video',
			),
			'allow_null' => 0,
			'other_choice' => 0,
			'default_value' => '',
			'layout' => 'horizontal',
			'return_format' => 'value',
			'save_other_choice' => 0,
		),
		array(
			'key' => 'field_5beebff0b6f68',
			'label' => 'Bild',
			'name' => 'media_large_image',
			'type' => 'image',
			'instructions' => '',
			'required' => 0,
			'conditional_logic' => array(
				array(
					array(
						'field' => 'field_5beebf6eb6f67',
						'operator' => '==',
						'value' => 'mlmt_image',
					),
				),
			),
			'wrapper' => array(
				'width' => '',
				'class' => '',
				'id' => '',
			),
			'return_format' => 'array',
			'preview_size' => 'thumbnail',
			'library' => 'all',
			'min_width' => '',
			'min_height' => '',
			'min_size' => '',
			'max_width' => '',
			'max_height' => '',
			'max_size' => '',
			'mime_types' => '',
		),
		array(
			'key' => 'field_5beec043b6f69',
			'label' => 'Video-Typ',
			'name' => 'media_large_video_type',
			'type' => 'radio',
			'instructions' => '',
			'required' => 0,
			'conditional_logic' => array(
				array(
					array(
						'field' => 'field_5beebf6eb6f67',
						'operator' => '==',
						'value' => 'mlmt_video',
					),
				),
			),
			'wrapper' => array(
				'width' => '',
				'class' => '',
				'id' => '',
			),
			'choices' => array(
				'mlvt_youtube' => 'Youtube-Video',
				'mlvt_mp4' => 'MP4-Video',
			),
			'allow_null' => 0,
			'other_choice' => 0,
			'default_value' => '',
			'layout' => 'horizontal',
			'return_format' => 'value',
			'save_other_choice' => 0,
		),
		array(
			'key' => 'field_5beec0b6b6f6a',
			'label' => 'Video-Youtube',
			'name' => 'media_large_video_youtube',
			'type' => 'youtubepicker',
			'instructions' => '',
			'required' => 0,
			'conditional_logic' => array(
				array(
					array(
						'field' => 'field_5beec043b6f69',
						'operator' => '==',
						'value' => 'mlvt_youtube',
					),
				),
			),
			'wrapper' => array(
				'width' => '',
				'class' => '',
				'id' => '',
			),
			'multiple' => 0,
			'yp_advanced_options' => 0,
			'api_key' => 'AIzaSyAuHQVhEmD4m2AXL6TvADwZIxZjNogVRF0',
			'answerOptions' => array(
				0 => 'title',
				1 => 'vid',
				2 => 'url',
				3 => 'thumbs',
				4 => 'iframe',
			),
			'channelId' => '',
			'channelType' => '',
			'eventType' => '',
			'order' => 'relevance',
			'safeSearch' => 'none',
			'videoCaption' => 'any',
			'videoDefinition' => 'any',
			'videoDimension' => 'any',
			'videoDuration' => 'any',
			'videoEmbeddable' => 'true',
			'videoLicense' => 'any',
			'videoSyndicated' => 'any',
			'videoType' => 'any',
			'videoCategoryId' => '',
			'relatedVideoId' => '',
			'topicId' => '',
			'regionCode' => '',
			'relevanceLanguage' => '',
			'maxResults' => '',
		),
		array(
			'key' => 'field_5bf28751d7441',
			'label' => '1. MP4-Video hochladen',
			'name' => 'media_large_video_mp4_upload',
			'type' => 'image',
			'instructions' => '(nach dem Hochladen des Videos, im zweiten Schritt das hochgeladene Video selektieren/zuweisen)',
			'required' => 0,
			'conditional_logic' => array(
				array(
					array(
						'field' => 'field_5beec043b6f69',
						'operator' => '==',
						'value' => 'mlvt_mp4',
					),
				),
			),
			'wrapper' => array(
				'width' => '',
				'class' => '',
				'id' => '',
			),
			'return_format' => 'array',
			'preview_size' => 'thumbnail',
			'library' => 'all',
			'min_width' => '',
			'min_height' => '',
			'min_size' => '',
			'max_width' => '',
			'max_height' => '',
			'max_size' => '',
			'mime_types' => '',
		),
		array(
			'key' => 'field_5beec101b6f6b',
			'label' => '2. MP4-Video auswählen',
			'name' => 'media_large_video_mp4',
			'type' => 'post_object',
			'instructions' => '',
			'required' => 0,
			'conditional_logic' => array(
				array(
					array(
						'field' => 'field_5beec043b6f69',
						'operator' => '==',
						'value' => 'mlvt_mp4',
					),
				),
			),
			'wrapper' => array(
				'width' => '',
				'class' => '',
				'id' => '',
			),
			'post_type' => array(
				0 => 'attachment',
			),
			'taxonomy' => '',
			'allow_null' => 0,
			'multiple' => 0,
			'return_format' => 'object',
			'ui' => 1,
		),
		array(
			'key' => 'field_5bd03b9ae654b',
			'label' => 'Text',
			'name' => 'media_large_text',
			'type' => 'wysiwyg',
			'instructions' => '',
			'required' => 0,
			'conditional_logic' => 0,
			'wrapper' => array(
				'width' => '',
				'class' => '',
				'id' => '',
			),
			'default_value' => '',
			'tabs' => 'all',
			'toolbar' => 'basic',
			'media_upload' => 1,
			'delay' => 0,
		),
		array(
			'key' => 'field_5bd03bc2e654c',
			'label' => 'Quellenangabe',
			'name' => 'media_large_media_source',
			'type' => 'text',
			'instructions' => '',
			'required' => 0,
			'conditional_logic' => 0,
			'wrapper' => array(
				'width' => '',
				'class' => '',
				'id' => '',
			),
			'default_value' => '',
			'placeholder' => '',
			'prepend' => '',
			'append' => '',
			'maxlength' => '',
		),
	),
	'min' => '',
	'max' => '',
),`

acf_bug

Field returns data in form of multiple videos even if "select multiple videos" is set no

Hi,

I just updated the plugin to 3.0.0 and I noticed that the field returns array which has array inside it as it would have multiple videos selected even if I have the "select multiple videos" set to no.

So as I have selected the video id before by using $video["vid"] now I get it by using $video[0]["vid"]

Is this normal behaviour of a bug?

I also noticed that when I sync in ACF it creates completely new Field Group instead of syncing and I can't remove the old one.

BTW Thanks for amazing plugin!

Including add-on within the theme

I wonder if it is possible to include this field within the theme without the need to install the plugin.

Currently, I included ACF Pro within the theme and tried including this plugin as well but without any success.

Using youtube picker in theme as normal input

Hi

I'm using this plugin in backend and it works very good. Good Job.
Do you think is possible to create a normal input(yb picker) in theme template(frontend) and have the same functionality?

Where i can find some help steps?

Thank you

Mixed Content Error when using the plugin on a https website

Everything work's fine on local and staging env(http), but when i try the plugin on production(https) i get an error like this:

Mixed Content: The page at https://example.com was loaded over HTTPS, but requested an insecure resource 'http://www.youtube.com/embed...'. This request has been blocked; the content must be served over HTTPS.

I specify that this problem is only when i search the video i want, and click on preview button.

Is there a setting where i can set to make the request over https? or i have to manualy modify the plugin?

Instruction on using the advanced options

First, thank you for this plugin. Very useful & user friendly.

The plugin has a lot of options if you consider the advanced options too. I'm struggling to understand what some of the advanced options do. It would be nice if the readme would have short descriptions for what each option field does / affects to.

I'm now struggling in restricting the search to a channel scope. I've obtained the channel ID and pasted it in the Channel ID field under the advanced options but the search still isn't restricted to videos on that channel. Any tips what I'm doing wrong? Is the API key related to this in some way?

Plugin sends "any" options to API

The Plugin currently sends all the options set, including anything set to "any", I have had this break a site before with the channelType option, not exactly sure why, but would be good to check and remove any option set to any from being added to the API call, this would also reduce the cost of the API call as well as every parameter adds to the cost of making the call.

Lack of searching indicator

It would be great to have some kind of indication of video searching process (that may take some time). Something like spin.js or CSS loader will look great or maybe just some animated image.

Multiple videos in repeater field issue

Hi there,

I have acf-youtube picker field inside a repeater field.

When editing the page, if I create a second repeater field and start to select videos, the video I select is shown in the first repeater field as well as the second repeater field.

Incorrect work inside ACF Repeater

Picker works incorrectly when used inside ACF Pro Repeater. Looks like its JS part doesn't expect multiple pickers on same page so when video is being selected - its thumbnail get updated into all pickers. Moreover when page with multiple pickers get submitted - it stores incorrect (sometimes even no) values into ACF structures. These problems currently makes your (otherwise great) plugin to be used in all scenarios.

Too tall field size

Picker field have min-height: 300px style for it that is fine in a case is multiple videos are selected. But it is too tall in a case of single video selector taking in mind that video preview height is only 90px

Get video URL only

Thanks for the plugin, very helpful.

Is there a possibility of providing a [video-url] key, so I don't have to manipulate the [iframe] key to get the video URL?

Incorrect thumbnails information is provided by plugin

At this moment list of thumbnails provided by plugin is hardcoded in a terms of both list of images and their sizes. It is absolutely unacceptable since it leads to incorrect information in a case if actually available list of thumbnails is either different or have different sizes. Here are example of YouTube API output for two videos:

v1
It can be seen that there is no "maximum" thumbnail is available at all, but plugin tells application that it is available - it leads to broken image on site.

v2
It can be seen that "maximum" (actually "maxres") thumbnail have different image size and, moreover, different aspect ratio (16:9 instead of 4:3). It leads to incorrect appearance of video thumbnail on site.

It is even more strange that information about thumbnails is hardcoded in plugin while plugin itself is able to work with YouTube API to retrieve information about video.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.