arc_youtube

Easily embed Youtube videos and playlists in articles and customise the appearance of the player.

I am aware that there are other Youtube plug-ins for Textpattern out there, but I believe mine is a little different.

With arc_youtube you can customise the appearance of the player, setting its size, colour scheme and more. Videos can be associated with articles using a custom field and are identified using either the video’s ID or URL.

Table of contents

  1. Plugin requirements
  2. Installation
  3. Tags
  4. Examples
  5. Author
  6. License

Plugin requirements

arc_youtube’s minimum requirements:

  • Textpattern 4.5+

Installation

To install go to the ‘plugins’ tab under ‘admin’ and paste the plugin code into the ‘Install plugin’ box, ‘upload’ and then ‘install’. Please note that you will need to set-up a custom field to use for associating videos with articles, unless you choose to directly embed the new tag in the article text.

Tags

arc_youtube

Embeds a Youtube video in the page using an iframe.

<txp:arc_youtube />

Video and playlist attributes

  • video – Youtube url1 or video ID for the video you want to embed
  • playlist – Youtube playlist ID for the playlist you want to embed
  • custom – Name of the custom field containing video IDs/urls associated with article
  • start – Start position of the video as an integer
  • auto – ‘1’ to autoplay the video, ‘0’ to turn off autoplay (default)
  • loop – ‘1’ to play the video in a loop, ‘0’ for a single play
  • playsinline – ‘1’ causes inline playback on iOS, ‘0’ fullscreen playback

1 The url can be either for an individual video or for a playlist.

Basic attributes

  • link – Set to ‘1’ to show a link to the Youtube video page below the player; the link text will be the URL or the text between opening and closing tags
  • label – Label for the video
  • labeltag – Independent wraptag for label
  • wraptagHTML tag to be used as the wraptag, without brackets
  • classCSS class attribute for wraptag

Customising the Youtube player

Some of the attributes with this plugin are subject to change if Youtube change their supported parameters for the player. Some will not work with the HTML5 player which the player defaults to if the browser supports it.

  • width – Width of video
  • height – Height of video
  • ratio – Aspect ratio (defaults to 4:3)
  • theme – Use either the “dark” or “light” Youtube player
  • color – Use either a “red” or “white” video progress bar
  • modestbranding – ‘1’ to prevent the YouTube logo from displaying in the control bar
  • fs – ‘1’ to allow full screen, ‘0’ to disable full screen mode2
  • cc – ‘1’ to display captions/subtitles by default, ‘0’ to use the user’s preference2
  • related – ‘1’ to show related videos, ‘0’ to turn them off
  • privacy – ‘1’ for enhanced privacy mode, no cookies unless the user clicks play, ‘0’ normal mode
  • autohide – ‘2’ for the video progress bar to fade out while the player controls (play button, volume control, etc.) remain visible; ‘1’ for the video progress bar and the player controls will slide out of view a couple of seconds after the video starts playing; or ‘0’ to always show the progress bar and controls
  • controls – ‘2’ to display the controls in the player, ‘0’ to hide them
  • annotations – ‘1’ to show annotations, ‘3’ to hide them
  • title – ‘0’ to hide the video’s title and other information, ‘1’ by default to show the information

2 Not supported by the HTML5 player.

arc_if_youtube

The arc_is_youtube tag is a conditional tag and always used as an opening and closing pair. It will render the content between the tags if the video attribute is a valid Youtube URL.

<txp:arc_if_youtube video="[URL]"></txp:arc_if_youtube>

Parameters

Use one or the other of the following:-

  • custom – Name of the custom field containing video IDs/urls associated with article
  • video – A URL to check if it is a valid Youtube URL

Examples

Example 1: Use custom field to associate video with an article

<txp:arc_youtube custom="Youtube" />

Example 2: Customise the appearance of the player and associate video with custom field

<txp:arc_youtube theme="light" modestbranding="1" custom="Youtube" />

This will use the light player theme with modest branding (i.e. removes the Youtube logo from the controls). As example 1, the video is selected using an article’s custom field called ‘Youtube’.

Example 3: Small video player with fixed video

<txp:arc_youtube width="200" video="tgbNymZ7vqY" />

Here the video is defined within the tag using the video attribute which has been given the value of Youtube’s video ID, alternatively this value could have been the video’s URL.

The Details


Comments

  1. Michael |

    Hello,
    somehow the plugin seems not to work.
    Did it according to your description and used following example
    <txp:arc_youtube v=“V5BxymuiAxQ” />
    but it does not show up.
    Any ideas?

  2. Andy |

    Michael, the attribute needs to be video not v; so in your case it would be:-

    <txp:arc_youtube video=“V5BxymuiAxQ” />

    Does that help?

  3. Giuseppe |

    Hi, Thanks a lot for this great plugin, really useful.
    Is it possible to embed playlists?

  4. Andy |

    Hi Giuseppe, I’ve just updated the plugin and have included the ability to embed playlists with the new version (v0.2). I hope this helps and I’m glad you are finding the plugin useful.

  5. Antti |

    Hi, when I put attribute in the html window and close it, it vanishes and no video is shown. Where should I paste this code, (e.g.)<txp:arc_youtube video=“V5BxymuiAxQ” />?

    Thanks in advance!
    Antti

  6. Andy |

    Antti, not quite sure quite what your issue is, but hope I can help. You can embed the arc_youtube tag directly in your article text (on the Write article / Text tab). When you save your article the video should be included on your site. Alternatively, the tag can be used on the pages and forms used for presentations.

    Also, remember to make sure that you have turned the plugin on on the Plugin manager page of your Textpattern installation.

  7. Matt |

    Hi,

    I just installed but I’m getting this error;

    Tag error: <txp:arc_youtube custom=“Youtube” /> -> Notice: Undefined variable: p on line 70

    The video still displays but I get that at the head of every page where the tag is used :(

  8. Andy |

    Matt, Sorry for being so unbelievably slow at looking into this. I’ve taken a quick look over the code and made a small modification to it that should hopefully remove the error message you are getting. I hope this sorts it, just download the latest version (v0.2.1).

  9. Lawrence |

    I tried using the plug-in, but when I try to embed a video, the video does not show up on the post and I get this error:

    Tag error: <txp:arc_youtube width=“200” height=“150” video=“BaqkcIQTHWA” /> -> Textpattern Warning: Attribute values must be quoted on line 916

    Tag error: <txp:arc_youtube width=“200” height=“150” video=“BaqkcIQTHWA” /> -> Textpattern Warning: Attribute values must be quoted on line 916

    Tag error: <txp:arc_youtube width=“200” height=“150” video=“BaqkcIQTHWA” /> -> Textpattern Warning: Attribute values must be quoted on line 916

    kind of a beginner at this, so what should I do?

  10. Andy |

    Hi Lawrence, make sure that all the attributes are quoted with vertical double quotation marks. Don’t copy and paste the quotation marks used above as Textpattern is formatting them to look nice but not in the correct format for use with the tags.

    Your tag should look like this:-

    <txp:arc_youtube width="200" height="150" video="BaqkcIQTHWA" />

  11. Philip |

    Hi,
    re the installation – I downloaded “arc_youtube_v0.3_zip.txt”, but in the preview pane (after uploading the code) it mentions 0.2.1. That ok?

  12. Andy Carter |

    Hi Philip, well spotted; that’s a minor mistake on my behalf! As long as the plugin says version 0.3 on the plugins table it’s fine. The version number you’re seeing is just a comment in the plugin’s code. I will remove it to avoid future confusion.

  13. Kurt |

    Thanks for the plugin; it’s just what I was looking for. Note the current version (1.0) throws an exception for me because the “hd” variable is used but not defined on line 118. I worked around it by adding ‘hd’ => 0 to the extract call.

  14. Andy |

    Thanks Kurt. This has now been fixed as of v1.0.1.

  15. Ross |

    Hi Andy.

    Very handy plugin – thanks very much! one tiny niggle, the hd=“1” attribute doesn’t seem to work.

    Example (scroll down):

    Alpheton Hall Barn Wedding

    Using this code:

    <txp:arc_youtube video=”<txp:custom_field name=‘youtube’ />” width=“830” height=“498” color=“white” hd=“1” theme=“dark” ratio=“16:9” />

    Any ideas? Would be the icing on the cake having it select 720p by default :¬)

    Thanks,
    Ross

  16. Andy |

    Hi Ross, glad you like the plugin.

    I’ve just taken a quick look into your issue with the HD parameter. It looks like you are using v1.x of the plugin which uses Youtube’s new player. According to Youtube the new player “will automatically play the version of the video that is appropriate for your player’s size.” In your case Youtube is choosing to ignore the HD setting. So unfortunately there’s nothing that can be done about this.

  17. varee |

    Hi,

    thanks very much for your plugin :)

  18. bob |

    Links to downloads above are leading to 404 page.

  19. D5000 |

    I get the 404 error too.

    Seems the plugin is now at Github:

    arc_youtube.txt

  20. Andy |

    Sorry folks. For some reason the files have been lost on the server. I will attempt to repair things here but in the meantime you can download the latest arc_youtube plugin from Github.

  21. Andy |

    Downloads are now working again. Sorry for the delay in getting these back up.

  22. Web-programmer |

    Good day dear author!
    Does your plugin work now – after the Youtube has finished the change if his API?
    Thank you in advance!

  23. Andy |

    Hi web-programmer, as long as you use the latest version of the plugin it should work fine.

Leave a Comment
  • You will need to preview your comment before you can submit it.