From 1b310625907fd635787022debc106abf120df108 Mon Sep 17 00:00:00 2001 From: "Philip M. Hofer (Frumph)" Date: Sat, 2 Jan 2010 10:49:59 -0800 Subject: [PATCH] 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) --- functions/displaycomic.php | 29 ++++++++++++++++++++++++++--- layout-head.php | 4 ++-- widgets/LatestThumbnailWidget.inc | 24 ++++-------------------- 3 files changed, 32 insertions(+), 25 deletions(-) diff --git a/functions/displaycomic.php b/functions/displaycomic.php index 50e5d73..68e0ddf 100644 --- a/functions/displaycomic.php +++ b/functions/displaycomic.php @@ -1,13 +1,36 @@ 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 = "\"".get_the_title()."\""; + break; + } + } + } + return apply_filters('comicpress_display_comic_image',$comic_image); +} + + +function comicpress_display_comic_area() { global $post, $wp_query, $comicpress_options; if (comicpress_check_child_file('partials/displaycomic') == false) { ?>
-
+
@@ -15,7 +38,7 @@ function display_comic_area() { is_single = true; - display_comic_area(); + comicpress_display_comic_area(); endwhile; } Restore(); @@ -35,7 +35,7 @@ wp_reset_query(); } if (is_single() & in_comic_category()) { - display_comic_area(); + comicpress_display_comic_area(); } ?> diff --git a/widgets/LatestThumbnailWidget.inc b/widgets/LatestThumbnailWidget.inc index 77aee92..4b5ead3 100644 --- a/widgets/LatestThumbnailWidget.inc +++ b/widgets/LatestThumbnailWidget.inc @@ -32,26 +32,10 @@ class ComicPressLatestThumbnailWidget extends WP_Widget { $archive_image = null; if (have_posts()) { while (have_posts()) : the_post(); - if (!empty($post->post_content)) { - echo $before_widget; - $temp_query = $wp_query->is_single; - $wp_query->is_single = true; - foreach (array("archive", "rss", "mini", "comic") as $type) { - if (($requested_archive_image = get_comic_url($type, $post)) !== false) { - $archive_image = "\"".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'); - } - } ?> - - is_single = $temp_query; - echo $after_widget; - } + $temp_query = $wp_query->is_single; + $wp_query->is_single = true; + echo "".comicpress_display_comic_image('rss,archive,mini,comic',true)."\r\n"; + $wp_query->is_single = $temp_query; endwhile; } Restore();