thumbnail change - comic post thumbnails will not display above the post for the comic post, the thumbnail is now used as an alternative for the latest thumbnail widget, if has_thumbnail the latest thumbnail widget will display that thumbnail inside the widget.

the_widget('ComicPressLatestThumbnailWidget','title=Latest Comic&onlyhome=true');

New option in the thumbnail 'onlyhome' will allow someone to have the thumbnail only display in on the homepage if widget enabled, off it will display everywhere it's placed.

Since it's a widget it can be used in site design for placement of an alternate image to the comic i.e. lfgcomic

Signed-off-by: Philip M. Hofer (Frumph) <frumph_dragon@yahoo.com>
This commit is contained in:
Philip M. Hofer (Frumph) 2009-12-26 08:06:56 -08:00
parent 0cc82d4c21
commit 0c271311b5
4 changed files with 40 additions and 24 deletions

View File

@ -14,9 +14,9 @@ function comicpress_display_post_title($is_comic = false) {
echo apply_filters('comicpress_display_post_title',$post_title);
}
function comicpress_display_post_thumbnail() {
function comicpress_display_post_thumbnail($is_comic = false) {
global $post;
if (function_exists('has_post_thumbnail')) {
if (function_exists('has_post_thumbnail') && !$is_comic) {
if ( has_post_thumbnail() ) {
$post_thumbnail = "<div class=\"post-image\"><a href=\"".get_permalink()."\" rel=\"bookmark\" title=\"Permanent Link to ".get_the_title()."\">".get_the_post_thumbnail($post->ID,'full')."</a></div>\r\n";
echo apply_filters('comicpress_display_post_thumbnail',$post_thumbnail);

View File

@ -10,7 +10,7 @@ if (!$comicpress_options['disable_lrsidebars_frontpage']) { ?>
the_widget('ComicPressArchiveDropdownWidget', 'mode=storyline_order');
}
if ($comicpress_options['disable_comic_frontpage']) {
the_widget('ComicPressLatestThumbnailWidget');
the_widget('ComicPressLatestThumbnailWidget','title=Latest Comic&onlyhome=true');
}
the_widget('WP_Widget_Pages');
the_widget('WP_Widget_Categories','hierarchical=1&count=1');

View File

@ -859,6 +859,16 @@ ul.children {
padding: 3px;
}
.sidebar .ComicPressLatestThumbnailWidget h2 {
text-align: left;
}
.sidebar .ComicPressLatestThumbnailWidget {
text-align: center;
}
/* WIDGETS */
.random-comic-icon, .random-post-icon {

View File

@ -19,12 +19,12 @@ class ComicPressLatestThumbnailWidget extends WP_Widget {
}
function widget($args, $instance) {
global $post;
if (is_home()) {
extract($args, EXTR_SKIP);
global $post, $wp_query;
if (!is_home() && $instance['onlyhome']) return;
extract($args, EXTR_SKIP);
echo $before_widget;
$title = empty($instance['title']) ? __('Latest Comic','comicpress') : apply_filters('widget_title', $instance['title']);
$title = empty($instance['title']) ? '' : apply_filters('widget_title', $instance['title']);
if ( !empty( $title ) ) { echo $before_title . $title . $after_title; };
$latestcomics = get_posts('numberposts=1&category='.get_all_comic_categories_as_cat_string());
$archive_image = null;
@ -32,29 +32,35 @@ class ComicPressLatestThumbnailWidget extends WP_Widget {
foreach($latestcomics as $post) :
foreach (array("archive", "rss", "mini", "comic") as $type) {
if (($requested_archive_image = get_comic_url($type, $post)) !== false) {
$archive_image = $requested_archive_image; break;
$archive_image = "<img src=\"$requested_archive_image\" alt=\"".get_the_title()."\" title=\"".get_the_title()."\" />";
break;
}
} ?>
<center>
<a href="<?php the_permalink(); ?>"><img src="<?php echo $archive_image ?>" alt="<?php the_title() ?> - <?php the_date(); ?>" title="<?php the_hovertext() ?>" /></a><br />
<span class="latest_thumbnail_date"><?php the_date(); ?></span>
</center>
}
if (function_exists('has_post_thumbnail')) {
if ( has_post_thumbnail($post->ID) ) {
$archive_image = get_the_post_thumbnail($post->ID,'full');
}
}
?>
<a href="<?php the_permalink(); ?>"><?php echo $archive_image; ?></a>
<?php endforeach;
echo $after_widget;
}
}
function update($new_instance, $old_instance) {
$instance = $old_instance;
$instance['title'] = strip_tags($new_instance['title']);
$instance['onlyhome'] = (bool)( $new_instance['onlyhome'] == 1 ? true : false );
return $instance;
}
function form($instance) {
$instance = wp_parse_args( (array) $instance, array( 'title' => '' ) );
$instance = wp_parse_args( (array) $instance, array( 'title' => '', 'onlyhome' => false ) );
$title = strip_tags($instance['title']);
$onlyhome = $instance['onlyhome'];
?>
<p><label for="<?php echo $this->get_field_id('title'); ?>"><?php _e('Title:','comicpress'); ?> <input class="widefat" id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" type="text" value="<?php echo attribute_escape($title); ?>" /></label></p>
<p><label for="<?php echo $this->get_field_id('onlyhome'); ?>"><input id="<?php echo $this->get_field_id('onlyhome'); ?>" name="<?php echo $this->get_field_name('onlyhome'); ?>" type="checkbox" value="1" <?php checked(true, $onlyhome); ?> /> Display only on the home page?</label></p>
<?php
}
}