TXP Plugins
arc_youtube :: Nov 15, 02:17 PM
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=“ta7VHKGuoJY” />
or,
<txp:arc_youtube video=“http://uk.youtube.com/watch?v=ta7VHKGuoJY” />
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” |
| 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
You can customise the appearance of the Youtube flash player using this plugin to define colours, size, and language settings.
| Attribute | Description | Default | Example |
|---|---|---|---|
| width | Width of video | 425 | width=“200” |
| height | Height of video | 344 | height=“150” |
| color1 | Six-digit hexadecimal colour code (if color1 and color2 are unset then the default Youtube colour scheme is used) | unset | color1=“2b405b” |
| color2 | Six-digit hexadecimal colour code | unset | color2=“6b8ab6” |
| border | ‘1’ to show border, ‘0’ to hide border | 0 | border=“1” |
| fs | ‘1’ to allow full screen, ‘0’ to disable full screen mode | 1 | |
| auto | ‘1’ to autoplay the video, ‘0’ to turn off autoplay (default) | 0 | |
| lang | Language code for player, by default this is set to English “en” | en | lang=“fr” |
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” height=“150” video=“ta7VHKGuoJY” />
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
- v0.2 (7/6/9)
- now works with playlists
- new ‘auto’ attribute to enable video autoplay
- updated help documentation
In development
In order of importance:-
Ensure valid XHTML output, currently the plugin fails on this.Fixed as of version 0.1.2.- Ability to embed multiple videos.
Plugin details
Initial release: 12 November 2008
Current version: 0.2.1
[ download ]
Please feel free to leave your comments and questions about this plugin below. Alternatively you can post them on the forum thread.
Use of my plugins is free; however, if you would like to show your appreciation you can do so by clicking the 'Donate' button below and make a contribution to the Andy Carter's coding fund via PayPal...
Comment
Recent plugins
Textpattern links
Textpattern forums
Textpattern's support forums.
Textpattern Resources
A directory of plugins, tutorials, and other resources for and by the Textpattern community.
TXP Tips
Tips, tutorials, and code to help build better Textpattern websites.
We Love TXP
Design gallery of sites using Textpattern.
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 · Jan 13, 07:11 AM · #
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 · Jan 13, 01:05 PM · #
Hi, Thanks a lot for this great plugin, really useful.
Is it possible to embed playlists?
— Giuseppe · Jun 4, 02:20 PM · #
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 · Jun 7, 05:54 PM · #
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 · Sep 4, 07:15 AM · #
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 · Sep 5, 12:05 PM · #
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 · Oct 28, 11:14 AM · #
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 · Nov 15, 02:20 PM · #
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 · Dec 2, 03:24 AM · #
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 · Dec 2, 05:06 PM · #