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();

Get the feeds

25 Responses to “apple’s trailers”

  1. 1

    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 am
  2. 2

    You can edit the get_trailer() function under the AppleTrailers.php file. You can remove unwanted <li>, <ul> tags.
    Hope this helps

    September 22nd, 2005 at 2:53 pm
  3. 3

    That was it…you are GREAT!
    Peace Out Brother Man.
    Hope you keep coding!

    September 23rd, 2005 at 3:37 am
  4. 4

    No problem! Glad i helped

    September 23rd, 2005 at 7:28 am
  5. 5

    Can you make it so you can pick which trailer to play instead of being a random one?

    October 1st, 2005 at 9:59 pm
  6. 6

    That’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 loadRandomD();. You can try loadRandomA() - loadRandomH()

    October 2nd, 2005 at 1:10 am
  7. 7

    BTW: thanks for this plugin. Such a cool choice for trailers.

    November 9th, 2005 at 12:03 pm
  8. 8

    You are welcome (:

    November 9th, 2005 at 12:05 pm
  9. 9

    Pretty damn sweet plugin man. GJ.
    I also would like a function to choose which trailer to show if possible.

    December 27th, 2005 at 9:48 pm
  10. 10

    Thank for your comment.
    For 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

    December 28th, 2005 at 1:40 pm
  11. 11

    Whoa! This is so totally awesome, dude! I run a dedicated movie blog, unfortunately in my native norwegian, but this suits perfectly.
    However, 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 :) Thanks, man!

    January 10th, 2006 at 2:16 am
  12. 12

    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!
    Also your blog looks interesting, too bad its not in English though \:

    January 10th, 2006 at 9:54 pm
  13. 13

    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 pm
  14. 14

    Wonderful 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….

    …..
    // 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();

    January 17th, 2006 at 9:48 am
  15. 15

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

    OK, this more or less did the trick, kinda proud now :)

    $border=’ border=”0″>’;
    $b=’/>’;
    $out = eregi_replace(”href=”/trailers/”,”href=”http://www.apple.com/trailers/”,
    eregi_replace($border,$b,$myfile));

    January 17th, 2006 at 9:56 pm
  17. 17

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

    “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.
    Garett your comment was moderated for some reason and i just found that out. I reposted it though..sorry for that (:

    January 22nd, 2006 at 11:00 pm
  19. 19

    I’m figuring it was because of all the outgoing links … but I could be wrong.

    January 25th, 2006 at 2:16 am
  20. 20

    Hi 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 am
  21. 21

    Thanks for the great plugin!

    March 29th, 2006 at 7:58 am
  22. 22

    Have 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 am
  23. 23

    Uhm, 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…! :D

    Anyway, thanks to Marios for putting it together in the first place…!

    September 30th, 2006 at 6:24 am
  24. 24

    Okay, 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 pm
  25. 25

    Where did you find it? Interesting read China holiday insurance multi trip

    February 21st, 2007 at 9:03 pm

Leave a Reply