Boing!
apple’s trailers
This plugin retrieves the JavaSript file from apple.com and shows a random movie from the array of movies. eregi_replace() is used to fix the links to point to the right path.
Download: Here (Right Click to save and rename from .txt to .php)
Installation: Put it into your wp-content/plugins directory and Activate it from the Plugins section
Usage: Just add to your sidebar <? get_trailer(); ?> and thats all.
Update 01-10-05: You can use different load event instead loadRandomD(); Valid functions are: loadRandomA(); - loadRandomH();
25 Responses to “apple’s trailers”
Leave a Reply
Things that 've been said
MaSOn: file poli kali doulia .Den ime sinithismenos na xrisimopio wp alla ta themes sou...
Expressed on 1st of Nov 2007
Manali: what new sowftware should be indroduced in the ipod?
Expressed on 7th of Mar 2007
Rebecca: Cool blog, interesting information... Keep it UP »
Expressed on 1st of Mar 2007
Daniel2: i meant 3.000
Expressed on 23rd of Feb 2007
Daniel2: DANG! you sure doing a good effort, bloody 30,000 pounds!? this i dont see...
Expressed on 23rd of Feb 2007
Stories from the Past

I did this and it seems to work but it makes the right hand sidebar wayyyy to big…can you give me some help.
Later
September 22nd, 2005 at 9:32 amYou can edit the get_trailer() function under the AppleTrailers.php file. You can remove unwanted <li>, <ul> tags.
September 22nd, 2005 at 2:53 pmHope this helps
That was it…you are GREAT!
September 23rd, 2005 at 3:37 amPeace Out Brother Man.
Hope you keep coding!
No problem! Glad i helped
September 23rd, 2005 at 7:28 amCan you make it so you can pick which trailer to play instead of being a random one?
October 1st, 2005 at 9:59 pmThat’s a good idea, i’ll try to do that using some javascript. Also you can choose a different list of trailers instead of the default by using different JS load event. Currently i am using
October 2nd, 2005 at 1:10 amloadRandomD();. You can tryloadRandomA()-loadRandomH()BTW: thanks for this plugin. Such a cool choice for trailers.
November 9th, 2005 at 12:03 pmYou are welcome (:
November 9th, 2005 at 12:05 pmPretty damn sweet plugin man. GJ.
December 27th, 2005 at 9:48 pmI also would like a function to choose which trailer to show if possible.
Thank for your comment.
December 28th, 2005 at 1:40 pmFor that you must look at apple’s JS file. You can start from there. Sorry but i don’t have time to implement such features. If you want any help on that though, let me know
Whoa! This is so totally awesome, dude! I run a dedicated movie blog, unfortunately in my native norwegian, but this suits perfectly.
Thanks, man!
January 10th, 2006 at 2:16 amHowever, there is a slight problem. I’ve tried to maintain STRICT XHTML in my coding, but, lol, this plugin skyrocketed the errors up to 196 or something regarding to W3C. I guess this comes from the .js files that’ being called. Guess there’s no way round this? If you bother you could click into my site, find the W3C XHTML 1.0 button down right and click on it, you can see that strict does not allow target=blank, border=0 and so on… Suggestions welcome, but I’m gonna use it anyway
Thank you for your comments and for using my plugin. The thing with XHTML is that it’s apple’s fault since the HTML in their .js file is not even XHTML 1.0 valid! You can of course open the file with fopen() or smthn and perform various eregi_replace() to replace the unwanted code. Another solution could be caching the .js file every night or smthn (it is very small in size). You can then strip the data locally and have the XHTML version of that file cached on your server. These workarounds just poped into my mind right now (: Hope i helped!
January 10th, 2006 at 9:54 pmAlso your blog looks interesting, too bad its not in English though \:
Thanks, Marios. Really appreciate it. However, my php knowledge is below zero - I tried to look up eregi_replace() but didn’t really get the hang of it… But I can see that you in AppleHeader.php do use it? As far as I can understand, the: eregi_replace(”href=”/trailers/”,”target=”_blank” href=”http://www.apple.com/trailers/”,$myfile) does search for href followed by /trailers/ and replaces it with target=_blank. Is this correct understood? To achieve XHTML 1.0 strict, I wouldn’t want this target=_blank, neither border=0. Any chance that YOU will make an XHTML-version of this?
January 11th, 2006 at 7:06 pmWonderful script!. I made a couple changes to tailer to the Japanese Apple Trailers. Unfortunately, there aren’t many trailers in the list to choose from. I had to create a random function between the three options mentioned above (loadRandomA, loadRandomD, loadRandomH). It seems to work. It’s a hack-job, but works….
…..
January 17th, 2006 at 9:48 am// ORIGINAL LINE http://wdirect.apple.com/trailers/home/externalA.js
$lines = file(”http://images.apple.com/jp/quicktime/trailers/rotation.js”);
…..
// CHANGED THE URL TO GRAB TRAILERS FROM APPLE JAPAN
$out = eregi_replace(”href=”/trailers/”,”target=”_blank” href=”http://www.apple.com/jp/quicktime/trailers/”,$myfile);
…..
srand((double)microtime()*1000000);
$blah = rand(1,3);
switch($blah) {
case 1:
echo “loadRandomA();
“;
break;
case 2:
echo “loadRandomD();
“;
break;
case 3:
echo “loadRandomH();
I really need help from you guys - I’m trying to modify this script with absolutely none-whatsover php-knowledge. I try to replace this string: border=”0″> with just an >. That is - I want to DELETE border=”0″.
For my life I can’t seem to do this.
What I’ve been trying to do is to link two eregi_replace together like this:
eregi_replace(”href=”/trailers/”,”href=”http://www.apple.com/trailers/”,eregi_replace(”border=”0″,”",$myfile));
However, it produces this result:
…2_the.gif” height=”60″ alt=”Switch” “>
That is, one ” is left behind… How do I do this??
January 17th, 2006 at 9:35 pmOK, this more or less did the trick, kinda proud now
$border=’ border=”0″>’;
January 17th, 2006 at 9:56 pm$b=’/>’;
$out = eregi_replace(”href=”/trailers/”,”href=”http://www.apple.com/trailers/”,
eregi_replace($border,$b,$myfile));
Cool plugin Marios, many thanks. A friend of mine (the Jonathan above) has been using this plugin for a bit, and I decided to try it out. After using it for about a day, I realized that it wasn’t cycling through all the trailers, just some of them. Also the tags outside of table were just bad form … so I rewrote the plugin to fix these issues.
If anyone is interested in it, the source code for it is available here: http://dev.zy.ca/wp-content/plugins/AppleTrailers/AppleTrailers.phps. If you wish to see what the incidental features this plugin allows, see http://dev.zy.ca/ (source) and http://dev.zy.ca/wp-trailers.php (source). Neither page is using the get_random_appletrailer() function in the code which duplicates the get_trailer() function from the original plugin … but it does work. See http://dev.zy.ca//wp-content/plugins/AppleTrailers/test.php (Source).
The plugin also caches the parsed Javascript files for one day (I figure that is probably good). The cache is assumed to be in the same directory as AppleTrailer.php with the name cache. cache has to writable to the apache/iis server so under unix, either make it owned by the webserver … or writable by the webserver (chmod 777 cache is the easiest way). The plug will function without the cache … it’s just slower … to speed it up, you’d probably want to remove the japanese trailers from the plugin … which are set with the second line of the options it $at_options.
January 18th, 2006 at 9:38 pm“The Man With The Plan” Glad you work that out. Sorry i didnt reply sooner but i was kind off busy with a new project that i am working on completely based on AJAX. Anyway it’s nice that users are updating things that i did just for fun (:
Also Garett and Jonathan pretty good job with the modifications.
January 22nd, 2006 at 11:00 pmGarett your comment was moderated for some reason and i just found that out. I reposted it though..sorry for that (:
I’m figuring it was because of all the outgoing links … but I could be wrong.
January 25th, 2006 at 2:16 amHi its me again,
Have you made a plugin that will use more of Apples trailers.
I was told that there needs to be more varity.
Hope you can help.
I looked at what others did on this page and i didn’t get it.
please Help…when you can.
See YA
January 25th, 2006 at 8:30 amThanks for the great plugin!
March 29th, 2006 at 7:58 amHave you ever been to ‘you tube’? they let you host videos there and you can hotlink them on your blogs. it’s really cool and you don’t have to bandwidth on the videos, cause its free.
April 8th, 2006 at 12:14 amUhm, will there be an updated version of the plugin, implementing Garett’s improvements…?! I’m just asking because I have no clue how I’d make those changes myself…
It sure is nice having the source code there, but it would be even cooler just having the improved plugin…!
Anyway, thanks to Marios for putting it together in the first place…!
September 30th, 2006 at 6:24 amOkay, I guess there is no updated version then…!? Too bad, because it’s generally a cool idea — but it kind of keeps cylcing thought the same few trailers again and again…!
October 4th, 2006 at 11:07 pmWhere did you find it? Interesting read China holiday insurance multi trip
February 21st, 2007 at 9:03 pm