Skip to content

Commit

Permalink
added option to display 'featured image' in the header, not in the po…
Browse files Browse the repository at this point in the history
…st content
  • Loading branch information
tfnab authored and beastaugh committed Feb 12, 2012
1 parent faf1b23 commit 999f082
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 4 deletions.
4 changes: 2 additions & 2 deletions app/templates/loop.php
Expand Up @@ -3,7 +3,7 @@
if (has_post_format('aside') || (get_tarski_option('asidescategory') && in_category(get_tarski_option('asidescategory')))) { // Aside loop ?>
<div <?php post_class('aside'); ?> id="p-<?php the_ID(); ?>">
<div class="content entry-content clearfix">
<?php echo tarski_post_thumbnail(); ?>
<?php if (!get_tarski_option('featured_header')) echo tarski_post_thumbnail(); ?>
<?php the_content(__('Read the rest of this entry &raquo;','tarski')); ?>
</div>

Expand All @@ -25,7 +25,7 @@
</div>

<div class="content entry-content clearfix">
<?php echo tarski_post_thumbnail(); ?>
<?php if (!get_tarski_option('featured_header')) echo tarski_post_thumbnail(); ?>
<?php the_content(__('Read the rest of this entry &raquo;','tarski')); ?>
</div>

Expand Down
3 changes: 3 additions & 0 deletions functions.php
Expand Up @@ -153,6 +153,9 @@

// Post thumbnails; change these settings via a child theme or plugin
add_theme_support('post-thumbnails');
if (get_tarski_option('featured_header'))
set_post_thumbnail_size(HEADER_IMAGE_WIDTH, HEADER_IMAGE_HEIGHT, true);
else
set_post_thumbnail_size(150, 150, false);

// Post types
Expand Down
2 changes: 1 addition & 1 deletion index.php
Expand Up @@ -16,7 +16,7 @@
</div>

<div class="content clearfix">
<?php echo tarski_post_thumbnail(); ?>
<?php if (!get_tarski_option('featured_header')) echo tarski_post_thumbnail(); ?>
<?php the_content(); ?>
</div>

Expand Down
4 changes: 4 additions & 0 deletions library/classes/options.php
Expand Up @@ -33,6 +33,8 @@ class TarskiOptions {
var $asidescategory;
var $centred_theme;
var $swap_sides;
var $swap_title_order;
var $featured_header;
var $tags_everywhere;
var $show_categories;
var $show_authors;
Expand Down Expand Up @@ -83,6 +85,7 @@ function set_defaults() {
'centred_theme' => true,
'swap_sides' => false,
'swap_title_order' => false,
'featured_header' => false,
'tags_everywhere' => true,
'show_categories' => true,
'show_authors' => true,
Expand Down Expand Up @@ -124,6 +127,7 @@ function tarski_options_update() {
$this->centred_theme = (bool) $_POST['centred_theme'];
$this->swap_sides = (bool) $_POST['swap_sides'];
$this->swap_title_order = (bool) $_POST['swap_title_order'];
$this->featured_header = (bool) $_POST['featured_header'];

unset($this->deleted);
}
Expand Down
3 changes: 2 additions & 1 deletion library/helpers/admin_helper.php
Expand Up @@ -316,7 +316,8 @@ function tarski_miscellaneous_options() {
'tags_everywhere' => __('Show tags everywhere', 'tarski'),
'centred_theme' => __('Centrally align the theme', 'tarski'),
'swap_sides' => __('Switch column order', 'tarski'),
'swap_title_order' => __('Reverse document title order', 'tarski'));
'swap_title_order' => __('Reverse document title order', 'tarski'),
'featured_header' => __('Featured images in header', 'tarski'));

foreach ($checkboxes as $name => $label)
$output .= tarski_option_checkbox($name, $label) . "\n\n";
Expand Down
12 changes: 12 additions & 0 deletions library/helpers/template_helper.php
Expand Up @@ -284,6 +284,16 @@ function tarski_headerimage() {

$header_img_url = get_header_image();

// inspired by twentyeleven
if ( get_tarski_option('featured_header') &&
is_singular() &&
has_post_thumbnail( $post->ID ) &&
( /* $src, $width, $height */ $image = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), array( HEADER_IMAGE_WIDTH, HEADER_IMAGE_WIDTH ) ) ) &&
$image[1] >= HEADER_IMAGE_WIDTH )
// Houston, we have a new header image!
$header_img_tag = get_the_post_thumbnail( $post->ID, 'post-thumbnail' );
else {

if (!$header_img_url) return;

$header_img_tag = sprintf('<img alt="%s" src="%s">',
Expand All @@ -292,6 +302,8 @@ function tarski_headerimage() {
: get_bloginfo('name'),
$header_img_url);

}

if (!(get_tarski_option('display_title') || is_front_page()))
$header_img_tag = sprintf(
'<a title="%s" rel="home" href="%s">%s</a>',
Expand Down

0 comments on commit 999f082

Please sign in to comment.