This is the website of Andy Carter a Textpattern and Drupal web developer living in the Steel city.

arc_youtube

Current release: version 1.0.1 (04/01/2012)

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 apply a border. Videos can be associated with articles using a custom field and are identified using either the video’s ID or URL.

Installation

To install go to the ‘plugins’ tab under ‘admin’ and paste the plugin code into the ‘Install plugin’ box, ‘upload’ and then ‘install’. Finally activate the plugin. 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.

Syntax

<txp:arc_youtube />

<txp:arc_youtube video="tgbNymZ7vqY" width="500" ratio="16:9" />

<txp:arc_youtube video="http://uk.youtube.com/watch?v=tgbNymZ7vqY" width="500" ratio="16:9" />

or,

<txp:arc_youtube link="1">Link</txp:arc_youtube>

Usage

Video and playlists
Attribute Description Default Example
video Youtube url1 or video ID for the video you want to embed unset video=“ta7VHKGuoJY”
playlist Youtube playlist ID for the playlist you want to embed unset playlist=“2DBFB60D581AB901”
start Start position of the video as an integer 0 start=“60”
custom Name of the custom field containing video IDs/urls associated with article Youtube ID custom=“video”

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

Basics
Attribute Description Default Example
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 0 link=“1”
label Label for the video no label label=“Youtube video”
labeltag Independent wraptag for label empty labeltag=“h3”
wraptag HTML tag to be used as the wraptag, without brackets unset wraptag=“div”
class CSS class attribute for wraptag arc_youtube class=“youtube”
Customising the Youtube player
Attribute Description Default Example
width Width of video 0 width=“200”
height Height of video 0 height=“150”
ratio Aspect ratio 4:3 ration=“16:9”
theme Use either the “dark” or “light” Youtube player dark theme=“light”
color Use either a “red” or “white” video progress bar red color=“white”
fs ‘1’ to allow full screen, ‘0’ to disable full screen mode 1
hd ‘1’ to play video in HD, ‘0’ to for normal play2 0
auto ‘1’ to autoplay the video, ‘0’ to turn off autoplay (default) 0
privacy ‘1’ for enhanced privacy mode, no cookies unless the user clicks play, ‘0’ normal mode 0 privacy=‘1’
ssl ‘1’ to use HTTPS protocol 0

2 The HD parameter may be ignored by Youtube. Youtube will display the video at a quality suitable for the players size.

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 color1="006699" color2="54abd6" border="1" custom="Youtube" />

This will place a border around the player and change its colour scheme to a blue one. 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.

Example 4: Youtube page link below player
<txp:arc_youtube link="1">Link to Youtube page</txp:arc_youtube>
Example 5: Embed a playlist
<txp:arc_youtube video="http://www.youtube.com/view_play_list?p=2DBFB60D581AB901" />

This embeds a Youtube playlist (a single player that cycles through the videos in the playlist). Alternatively the playlist ID can be used using the ‘playlist’ attribute:-

<txp:arc_youtube playlist="2DBFB60D581AB901" />

Change-log

  • v1.0.1 (4/1/12)
    • HD parameter bug fixed
  • v1.0 (4/12/11)
    • Moved over to the new iFrame Youtube player
  • v0.4 (4/12/11)
    • bug fixes
    • support for youtu.be short URLs
  • v0.3 (4/7/10)
    • Aspect ratio added
    • HD option and enhanced privacy setting
  • v0.2 (7/6/9)
    • now works with playlists
    • new ‘auto’ attribute to enable video autoplay
    • updated help documentation
The content of this page was first posted on Sunday December 4, 2011 and was last modified on Saturday January 28, 2012.

Plugin downloads

arc_youtube_v1.0.1.txt [14.36KB] Last modified: Wednesday January 4, 2012
arc_youtube_v0.4.txt [15.06KB] Last modified: Sunday December 4, 2011
arc_youtube v0.4

Comment

  1. 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?

    Michael · Tue Jan 13, 07:11 AM

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

    <txp:arc_youtube video=“V5BxymuiAxQ” />

    Does that help?

    Andy · Tue Jan 13, 01:05 PM

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

    Giuseppe · Thu Jun 4, 02:20 PM

  4. 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.

    Andy · Sun Jun 7, 05:54 PM

  5. 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

    Antti · Fri Sep 4, 07:15 AM

  6. 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.

    Andy · Sat Sep 5, 12:05 PM

  7. 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 :(

    Matt · Wed Oct 28, 11:14 AM

  8. 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).

    Andy · Sun Nov 15, 02:20 PM

  9. 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?

    Lawrence · Wed Dec 2, 03:24 AM

  10. 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" />

    Andy · Wed Dec 2, 05:06 PM

  11. 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?

    Philip · Mon Aug 2, 04:30 PM

  12. 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.

    Andy Carter · Mon Aug 2, 05:35 PM

  13. 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.

    Kurt · Sun Jan 1, 05:02 PM

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

    Andy · Wed Jan 4, 06:15 PM

  15. 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

    Ross · Sat Jan 28, 01:38 AM

  16. 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.

    Andy · Sat Jan 28, 10:19 AM

Want to comment?

To comment you'll need to provide an e-mail address. Don't worry all e-mail addresses are kept private and will never be shown on this site or distributed to others.

Don't forget the http:// part

You'll need to preview your comment before it can be submitted; this is to help prevent spam and to give you a chance to review your comment before it gets posted on the site.

Comment formatting:

_emphasis_
*strong*
??citation??
-deleted text-
+inserted text+
^superscript^

Hyperlink:
"link text":http://link.com/

To define an acronym:
ABC(Always Be Closing)

Note: All (X)HTML tags will be escaped.

Textpattern links