newism / craft3-fields

Address, telephone, email, embed and gender fields for CraftCMS 3.x
Other
54 stars 16 forks source link

Add the ability to get embed iframe code with Vimeo protected videos #24

Closed romainpoirier closed 6 years ago

romainpoirier commented 6 years ago

Using a Vimeo video protected with password, and even if Vimeo video embed is enabled in the vimeo.com settings, the embed object has no 'code' data (whereas it has when the video is not protected).

leevigraham commented 6 years ago

Example url?

romainpoirier commented 6 years ago

You can try this one: https://vimeo.com/218439987

leevigraham commented 6 years ago

Embed works by pulling the meta data from the url you enter. Given the page has no meta data (password protected) there's nothing to find. In this case I would recommend a different plugin.

romainpoirier commented 6 years ago

Even if there's no meta data to find it doesn't mean the link can't be embed. It would be great if it may return at least the HTML iframe tag.

For your information, I finally found a quick and dirty solution using Twig:

{% set videoData = item.videoEmbed.embedData %}
{% set videoId = videoData.url | replace({ 'https': '', 'http': '', '://vimeo.com/': '' }) %}
{% set embedCode = '<iframe src=\"https://player.vimeo.com/video/' ~ videoId ~ '\" width=\"640\" height=\"360\" frameborder=\"0\" title=\"' ~ (videoData.title | raw) | e('html')) ~ '\" webkitallowfullscreen mozallowfullscreen allowfullscreen></iframe>' %}