Advertisement
BakerMan

Event Calendar post thumbnail logic

Aug 6th, 2012
164
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.84 KB | None | 0 0
  1. /**
  2.  * I'll concentrate on the post thumbnail code here. The other
  3.  * stuff should be left just as Jonah had it.
  4.  *
  5.  * In this first example I am using the default "post-thumbnail"
  6.  * size and I am additionally assigning the "alignleft" CSS class
  7.  * (most themes use this to apply a float:left).
  8.  *
  9.  * I'm also doing a bit of a hack here by specifying the image
  10.  * width (in this case 100px) as an inline style (it's hackish
  11.  * because the width and height are already present in the img
  12.  * tag output, and we're overriding those). So, this should work
  13.  * but arguably isn't ideal.
  14.  */
  15. the_post_thumbnail('post-thumbnail', array(
  16.     'class' => 'alignleft',
  17.     'style' => 'width: 100px'
  18. ));
  19.  
  20.  
  21. /**
  22.  * A slight improvement would be to add a new CSS class, here I
  23.  * have used "featured-event-thumb" and you would then add additional
  24.  * stylesheet rules to control it's appearance, size etc, something
  25.  * like this:
  26.  *
  27.  *  img.featured-event-thumb {
  28.  *      float: left;
  29.  *      height: 100px;
  30.  *      margin-right: 10px;
  31.  *      width: 100px;
  32.  *  }
  33.  */
  34. the_post_thumbnail('post-thumbnail', array(
  35.     'class' => 'featured-event-thumb',
  36. ));
  37.  
  38.  
  39. /**
  40.  * One final variation could be to register a new post thumbnail
  41.  * size and use that in place of the default "post-thumbnail"
  42.  * size. Here I have used the notional "event-thumbnail" size.
  43.  *
  44.  * You would specify the target size in the thumbnail registration
  45.  * code, the benefit of this approach being that the image sent
  46.  * to the browser would be the correct size straight off the bat,
  47.  * no wasted bandwidth.
  48.  *
  49.  * If you want to find about more about registering post
  50.  * thumbnail sizes then see the following link.
  51.  *
  52.  * @see http://codex.wordpress.org/Function_Reference/add_image_size
  53.  */
  54. the_post_thumbnail('event-thumbnail', array(
  55.     'class' => 'featured-event-thumb',
  56. ));
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement