Skip to content

Instantly share code, notes, and snippets.

@jawinn
Created December 17, 2013 21:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jawinn/8012560 to your computer and use it in GitHub Desktop.
Save jawinn/8012560 to your computer and use it in GitHub Desktop.
Snazzy Layout 3 (old)
<div class="sz_cont <?php echo ( ( $post->post_type=='page' ) ? "sz_page" : "sz_post" ) ?>" >
<a class="sz_title" href="<?php echo $url ?>"><?php echo $title ?></a>
<?php // GET THE FIRST IMAGE ATTACHMENT ?>
<?php
$args = array(
'numberposts' => 1,
'order'=> 'ASC',
'post_mime_type' => 'image',
'post_parent' => $post->ID,
'post_status' => null,
'post_type' => 'attachment'
);
$attachments = get_children( $args );
if ($attachments) {
foreach($attachments as $attachment) {
if ( wp_get_attachment_image_src( $attachment->ID, 'thumbnail' ) ) {
$image_attributes = wp_get_attachment_image_src( $attachment->ID, 'thumbnail' );
} else {
$image_attributes = wp_get_attachment_image_src( $attachment->ID, 'full' );
}
}
}
?>
<?php // IMAGE IN POST: image url found in the post content (original default functionality) ?>
<?php $imageurl = $this->getImageUrl($imageurl, 110); ?>
<?php if ($attachments) : ?>
<a class="snazzy-image" href="<?php echo $url; ?>">
<div class="sz_img" style="background: transparent url('<?php echo wp_get_attachment_thumb_url( $attachment->ID ); ?>') no-repeat center;" ></div>
</a>
<div class="sz_excerpt"><?php echo ($comcount ? "<strong>$comcount comments</strong>" : "") ?></div>
<?php elseif ($imageurl) : ?>
<a class="snazzy-image" href="<?php echo $url; ?>">
<div class="sz_img" style="background: transparent url('<?php echo $imageurl ?>') no-repeat center;" ></div>
</a>
<div class="sz_excerpt"><?php echo ($comcount ? "<strong>$comcount comments</strong>" : "") ?></div>
<?php elseif ($excerpt) : ?>
<div class="sz_excerpt">&#8220;<?php echo $excerpt ?>&#8221; <?php echo ($comcount ? "<br/><strong>$comcount comments</strong>" : "") ?></div>
<?php endif; ?>
</div>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment