new function comicpress_display_comic_image() which you can pass a string "archive,rss,mini,comic" whatever order you want to try first, as well as can pass boolean use thumbnail which will check if the post has a thumbnail image if so use that and bypass the other thumbs

echo comicpress_display_comic_image("rss,comic", true);
is a valid usage, will check if there's a thumbnail for the post and use that, otherwise check the rss directory for an image, if can't find that, default to the comic directory.

Signed-off-by: Philip M. Hofer (Frumph) <frumph_dragon@yahoo.com>
This commit is contained in:
Philip M. Hofer (Frumph) 2010-01-02 10:49:59 -08:00
parent 9e334d8998
commit 1b31062590
3 changed files with 32 additions and 25 deletions

View File

@ -1,13 +1,36 @@
<?php <?php
function display_comic_area() { function comicpress_display_comic_image($searchorder = "comic",$use_post_image = false) {
global $post;
if ($use_post_image) {
if (function_exists('has_post_thumbnail')) {
if ( has_post_thumbnail($post->ID) ) {
$comic_image = get_the_post_thumbnail($post->ID,'full');
}
}
}
if (!isset($comic_image)) {
$searchorder = explode(',',$searchorder);
$requested_archive_image = '';
foreach ($searchorder as $type) {
if (($requested_archive_image = get_comic_url($type, $post)) !== false) {
$comic_image = "<img src=\"$requested_archive_image\" alt=\"".get_the_title()."\" title=\"".get_the_title()."\" />";
break;
}
}
}
return apply_filters('comicpress_display_comic_image',$comic_image);
}
function comicpress_display_comic_area() {
global $post, $wp_query, $comicpress_options; global $post, $wp_query, $comicpress_options;
if (comicpress_check_child_file('partials/displaycomic') == false) { ?> if (comicpress_check_child_file('partials/displaycomic') == false) { ?>
<div id="comic-wrap"> <div id="comic-wrap">
<div id="comic-head"><?php get_sidebar('over'); ?></div> <div id="comic-head"><?php get_sidebar('over'); ?></div>
<div class="clear"></div> <div class="clear"></div>
<?php get_sidebar('comicleft'); ?> <?php get_sidebar('comicleft'); ?>
<div id="comic"><?php display_comic(); ?></div> <div id="comic"><?php comicpress_display_comic(); ?></div>
<?php get_sidebar('comicright'); ?> <?php get_sidebar('comicright'); ?>
<div class="clear"></div> <div class="clear"></div>
<div id="comic-foot"><?php get_sidebar('under'); ?></div> <div id="comic-foot"><?php get_sidebar('under'); ?></div>
@ -15,7 +38,7 @@ function display_comic_area() {
<?php } <?php }
} }
function display_comic() { function comicpress_display_comic() {
global $post, $wp_query, $rascal_says, $comicpress_options, $comic_filename_filters; global $post, $wp_query, $rascal_says, $comicpress_options, $comic_filename_filters;
$next_comic = get_next_comic_permalink(); $next_comic = get_next_comic_permalink();
$comic = explode(".", the_comic_filename()); $comic = explode(".", the_comic_filename());

View File

@ -27,7 +27,7 @@
if (have_posts()) { if (have_posts()) {
while (have_posts()) : the_post(); while (have_posts()) : the_post();
$wp_query->is_single = true; $wp_query->is_single = true;
display_comic_area(); comicpress_display_comic_area();
endwhile; endwhile;
} }
Restore(); Restore();
@ -35,7 +35,7 @@
wp_reset_query(); wp_reset_query();
} }
if (is_single() & in_comic_category()) { if (is_single() & in_comic_category()) {
display_comic_area(); comicpress_display_comic_area();
} }
?> ?>

View File

@ -32,26 +32,10 @@ class ComicPressLatestThumbnailWidget extends WP_Widget {
$archive_image = null; $archive_image = null;
if (have_posts()) { if (have_posts()) {
while (have_posts()) : the_post(); while (have_posts()) : the_post();
if (!empty($post->post_content)) {
echo $before_widget;
$temp_query = $wp_query->is_single; $temp_query = $wp_query->is_single;
$wp_query->is_single = true; $wp_query->is_single = true;
foreach (array("archive", "rss", "mini", "comic") as $type) { echo "<a href=\"".get_permalink()."\">".comicpress_display_comic_image('rss,archive,mini,comic',true)."</a>\r\n";
if (($requested_archive_image = get_comic_url($type, $post)) !== false) {
$archive_image = "<img src=\"$requested_archive_image\" alt=\"".get_the_title()."\" title=\"".get_the_title()."\" />";
break;
}
}
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
$wp_query->is_single = $temp_query; $wp_query->is_single = $temp_query;
echo $after_widget;
}
endwhile; endwhile;
} }
Restore(); Restore();