Willkommen auf der privaten Homepage von Johannes Jarolim, Salzburg, Österreich

Welcome to the private homepage of Johannes Jarolim, Salzburg, Austria, Europe.

This is a YAPB post

15. March 2007, 11:17

Ready to use templates

211

Since there’s a growing community of YAPB-Users maintaining and posting on beautiful photoblogs, it was only a matter of time until the first YAPB-Ready WordPress themes would appear. Beside of creating some themes on my own (just need some time for that), my intention is to publish links to all available YAPB-ready-themes on this page:

YAPB Ready WordPress Themes

Grain

Author: Mac
Page: http://mac.defx.de/grain-theme
Preview: http://www.defx.de/
Type: Classical photoblog, dark

The first released YAPB theme: Grain. A very nice classical photoblog theme with a homepage presenting the latest image. Does have an image-mosaic feature (like my one ;-) ). Very straight layout accenting the image and not distracting the visitors eye through graphical tinsel. I do highly recommend it.

phT

Author: Fran Simó
Page: http://pht.inhubi.com/
Preview: http://justpictures.es/
Type: Base Theme, dark

The second theme i’ve found: The phT Theme from Fran Simó. According to the author it’s a base theme that you can take to develop your own style.

Monolit

Author: Kim Nørgaard
Page: http://blog.jasen.dk/monolit
Preview: http://blog.jasen.dk
Type: Classical photoblog, bright

The third theme in the collection: Monolit from Kim Nørgaard. I do like light and straight themes very much - A pitty it doesn’t support exif. Nevertheless a very nice theme for photographers. Thumbs up!

Reflection

Author: Dave
Page: http://xyloid.org/projects/reflection/
Preview: http://photoblog.xyloid.org/
Type: Classical photoblog, dark

This one will get some attention for sure: Reflection by dave. Pro: Very nice and clear dark theme pimped up with stylish JavaScript reflections. Con: Doesn’t look exactly the same in IE as stated out on daves todo list. Maybe someone out there helping him with that small issue?

Coming maybe: Unwakeable

Author: T. Longren
Page: http://www.longren.org/unwakeable/
Announcement: http://www.lon…/unwakeable-status-version-bump/

Coming maybe: According to the author, Unwakeable 2.0 will support YAPB out of the box. Since we now wait for a long time

You have a YAPB-Ready-Theme?

Just drop a note to the forum or a comment to this page and i’ll include it in the list.
Please make sure to include the used version of YAPB with your templates .zip so users may even use it if i’d decide to implement big changes in newer versions.

Happy photoblogging!

This is a YAPB post

25. August 2006, 21:15

Adapting templates

96

First of all: Adapting your theme to be “YAPB-Ready” is definitely no magic (Or as Douglas Adams used to write: Don’t Panic ;-). There are just a few points to know and your way to an attractive and individual photoblog is free.

Does adapting a theme sounds like rocket science to you? Maybe one of the Ready-to-use-templates meets your taste.

The Basics

YAPB gives the possibility to attach photos/images to your posts and to display them in various formats and styles. This section describes the first essential things you can do in your blogs template. If you decide to adapt your theme manually, don’t forget to turn off the automatic-image-insertion feature on the YAPB Options page.

Do it in the loop

First of all: All those code samples described underneath have to be used in the loop.

Checking for image existance

Since you’re free to post normal Wordpress articles or photoblog entries, there must be a possibility to check wheter the current displayed post is a photoblog post or not - Nothing easier than that:

<?php if (yapb_is_photoblog_post()): ?>
  <!-- This definitly is a YAPB Photoblog post -->
<?php else: ?>
  <!-- No image attached: This is a normal WordPress post -->
<?php endif ?>

Displaying the image

Now we know that we have an image, we want to display it:

<?php if (yapb_is_photoblog_post()): ?>
  <?php yapb_image('', array('alt' => 'My marvelous image'), '') ?>
<?php else: ?>
  ...
<?php endif ?>

For more information on yapb_image() and yapb_get_image() refer to the template functions documentation

Displaying a thumbnail

To one of the interesting parts: thumbnailing. YAPB uses phpThumb, a very stable and mature PHP library, for it’s thumbnailing. YAPB tries to hide all those nasty details and offers you a simple and refreshing template function which does all that resizing, caching and displaying-stuff for you:

<?php if (yapb_is_photoblog_post()): ?>

  <?php

    echo yapb_get_thumbnail(
      '<div>', // HTML before image tag
      array(
        'alt' => 'My marvelous first thumbnail', // image tag alt attribute
        'rel' => 'lightbox'                      // image tag rel attribute
      ),
      '</div>',               // HTML after image tag
      array('w=200', 'q=90'), // phpThumb configuration parameters
      'thumbnail'             // image tag custom css class
    );

  ?>

<?php else: ?>
  ...
<?php endif ?>

Nearly the same as yapb_image() - But with additional phpThumb configuration parameters that define the desired size and css class of your thumbnail image.

Displaying EXIF data

The next cool thing to do is displaying the EXIF data of your image. YAPB does use the easy-to-use library phpExifRW and tries to hide it’s complexity from you as always:

<?php if (yapb_is_photoblog_post()): ?>

  <h3>EXIF</h3>
  <ul>

  <?php

    yapb_exif(
      'li-exif',   // CSS Class for the LIs
      ': ',        // Separator between EXIF token name and value
      '<strong>',  // HTML before EXIF token name
      '</strong>', // HTML after EXIF token name
      '<i>',       // HTML before EXIF token value
      '</i>'       // HTML after EXIF token value
    )

  ?>

  </ul>

<?php else: ?>
  ...
<?php endif ?>

Have a look into the according documentation to see what can be done with this template function.

More advanced stuff

This section won’t only highlight the more complex templating possibilites, but also some general WordPress functionality that may spice up your theme:

Attaining the YAPB-Imageobject directly

Templating functions are cool - Until you need to, let’s say… display the thumbnail of a post not included in the current loop. So there should be a way to get grip on the YAPB Image Object directly to attain full control.

Example: You’re fetching one post out of the DB by using get_next_post() and want to know if it’s a photoblog article:

<?php

  // Use the WP Infrastructure to get the next post

  $theNextPost = get_next_post(); 

  // Check if we've gotten something

  if (!empty($nextPost)) {

    // Yes, we have a next post
    // Let's check if it has an image attached:

    if (!is_null($image = YapbImage::getInstanceFromDb($theNextPost->ID))) {

      // Yes, we have an image
      echo 'Heureka! The next post is a photoblog article.';

    } else {

      // no image ahead
      echo 'Alas! Just a normal WordPress article ahead.';

    }

  }

?>

Thumbnail navigation (previous and next image)

Since we know how to get the image object by hand, we could now use this know-how to create a little “next image, previous image” navigation with thumbnails as links.

I only show the code for the “next post” part - The “previous post” part is basically the same thing with usage of the get_previous_post() function:

<?php

  // Use the WP Infrastructure to get the next post

  $theNextPost = get_next_post(); 

  // Check if we've gotten something

  if (!empty($nextPost)) {

    // Yes, we have a next post
    // Let's check if it has an image attached:

    if (!is_null($image = YapbImage::getInstanceFromDb($theNextPost->ID))) {

      // Yes, we have an image
      // Let's define the thumbnail configuration

      $thumbnailConfiguration = array(
        'w=75', // 75 pixels width
        'h=75', // 75 pixels height
        'zc=1'  // crop the image
      );

      // And output the image tag

      echo '<a href="' . get_permalink($theNextPost->ID) . '">';
      echo '<img ' .
        'border="0" ' .
        'src="' . $image->getThumbnailHref($thumbnailConfiguration) . '" ' .
        'alt="To the next post" ' .
        'width="' . $image->getThumbnailWidth($thumbnailConfiguration) . '" ' .
        'height="' . $image->getThumbnailHeight($thumbnailConfiguration) . '" ' .
        '/>';
      echo '</a>';

    } else {

      // no image - we display a text link
      echo '<a href="' . get_permalink($theNextPost->ID) . '">To the next post</a>';

    }
  }

?>

For more information on the YAPB Image Object, just have a look into the lib/YapbImage.class.php - It should be documented sufficiently.

More to follow

So much for now - If you have ideas and code samples for this page - Leave a comment or post something in the forum - I’ll take a look.