pastebin - collaborative debugging

pastebin is a collaborative debugging tool allowing you to share and modify code snippets while chatting on IRC, IM or a message board.

This site is developed to XHTML and CSS2 W3C standards. If you see this paragraph, your browser does not support those standards and you need to upgrade. Visit WaSP for a variety of options.

paste-bin - collaborative debugging tool View Help


Posted by Anonymous on Wed 17th Jan 06:03
download | new post

  1. <?php
  2. /*
  3. Plugin Name: Virgo
  4. Plugin URI: http://jamietalbot.com/wp-hacks/virgo/
  5. Description: Mini photo switcher for WordPress.<br />Licensed under the <a href="http://www.opensource.org/licenses/mit-license.php">MIT License</a>, Copyright &copy; 2006 Jamie Talbot.
  6. Version: 0.1
  7. Author: Jamie Talbot
  8. Author URI: http://jamietalbot.com/
  9.  
  10. CME, simple first pass at image switcher.
  11.  
  12. Instructions:
  13.  
  14. * Write a post and use the upload section of the post page to upload photos.
  15. * Give your images a title of linked_image_1, linked_image_2, etc. and a sensible description.  You can
  16.         change 'linked_image' to something else - see below.
  17. * Save your post.
  18. * In your theme file, inside the loop (just before the_content(); is a good place), place virgo();
  19. * When you load up your page, you'll see the first image large, plus thumbnails underneath.  Clicking
  20.         on the thumbnails will load the full picture in the main section.
  21. * Use the classnames below (virgo_container, virgo_main_photo, virgo_photo_stream) and CSS to integrate
  22.         it into your theme.
  23.  
  24. Any questions, let me know,
  25.  
  26. Jamie.
  27.  
  28. */
  29.  
  30. // This is the maximum number of thumbnails that will be selected for each post.
  31. define ('VIRGO_MAX_PHOTOS', 5);
  32.  
  33. // This is the prefix of your photo titles - you can change this to whatever you like, but once you
  34. // have decided on a prefix, you should stick to it otherwise you'll lose links you've already created.
  35. define ('VIRGO_IMAGE_PREFIX', 'linked_image');
  36.  
  37. // This is some example CSS, change it to whatever you like.  Put it in your theme's main
  38. // style.css instead if you want.
  39. ?>
  40. <style type="text/css">
  41. .virgo_container {
  42.         background: #000;
  43.         border-top: 1px solid #000;
  44.         border-left: 1px solid #000;
  45.         border-right: 1px solid #000;
  46.         border-bottom: 1px solid #000;
  47. }
  48.  
  49. #virgo_main_photo {
  50.         margin: 10px auto;
  51.         display: block;
  52.         border: 4px solid #fff;
  53. }
  54.  
  55. .virgo_thumb_photo {
  56.         border: 4px solid #fff;
  57.         margin-left: 5px;
  58.         padding: 0;
  59. }
  60.  
  61. </style>
  62. <?php
  63.  
  64. function virgo () {
  65.         global $wpdb, $post;
  66.        
  67.         if ($photos = $wpdb->get_results("SELECT guid AS file, post_title AS title, post_content AS description FROM $wpdb->posts WHERE post_status = 'attachment' AND post_parent = $post->ID AND post_title LIKE '" . VIRGO_IMAGE_PREFIX ."%' LIMIT " . VIRGO_MAX_PHOTOS)) {
  68.                 ?>
  69.                 <script type="text/javascript">
  70.                 function virgo_switch(url, title) {
  71.                         document.getElementById('virgo_main_photo').src = url;
  72.                         document.getElementById('virgo_main_photo').title = title;
  73.                 }
  74.                 </script>
  75.                 <div class="virgo_container">
  76.                   <div class="virgo_main_photo">
  77.                     <img id="virgo_main_photo" src="<?php echo $photos[0]->file ?>" title="<?php echo $photos[0]->description ?>" alt="<?php echo $photos[0]->title ?>" />
  78.                   </div>
  79.                         <div class="virgo_photo_stream">
  80.                         <?php
  81.                         foreach ($photos as $photo) {
  82.                                 $thumb = substr($photo->file, 0, ($period = strrpos($photo->file, '.') + 1)) . 'thumbnail' . substr($photo->file, $period - 1);
  83.                                 ?>
  84.                                 <img class="virgo_thumb_photo" onclick="virgo_switch('<?php echo $photo->file ?>', '<?php echo $photo->description ?>')" src="<?php echo $thumb ?>" title="<?php echo $photo->description ?>" alt="<?php echo $photo->title ?>" />
  85.                                 <?php
  86.                         }
  87.                         ?>
  88.                         </div>
  89.                         <span style="float: right;"><a href="http://jamietalbot.com/wp-hacks/virgo/" title="Powered by Virgo" style="color: #fff;">Virgo</a></span>
  90.                         <div style="clear: both"></div>
  91.                 </div>
  92.                 <?php
  93.         }
  94. }
  95.  
  96.  
  97. ?>

Submit a correction or amendment below. (click here to make a fresh posting)
After submitting an amendment, you'll be able to view the differences between the old and new posts easily.

Use syntax highlighting

To highlight particular lines, prefix each line with @@


Remember my settings