mirror of
https://github.com/10h30/display-featured-image-genesis.git
synced 2026-07-11 18:46:03 +09:00
Fix post type archive widget if there is no image
This commit is contained in:
@@ -73,6 +73,7 @@ class Display_Featured_Image_Genesis_Widget_CPT extends WP_Widget {
|
||||
|
||||
$post_type = get_post_type_object( $instance['post_type'] );
|
||||
$option = get_option( 'displayfeaturedimagegenesis' );
|
||||
$image_id = '';
|
||||
|
||||
if ( 'post' === $instance['post_type'] ) {
|
||||
$frontpage = get_option( 'show_on_front' ); // either 'posts' or 'page'
|
||||
@@ -86,6 +87,7 @@ class Display_Featured_Image_Genesis_Widget_CPT extends WP_Widget {
|
||||
$title = get_bloginfo( 'name' );
|
||||
$permalink = home_url();
|
||||
}
|
||||
$image_id = $postspage_image;
|
||||
}
|
||||
else {
|
||||
$title = $post_type->label;
|
||||
@@ -104,8 +106,10 @@ class Display_Featured_Image_Genesis_Widget_CPT extends WP_Widget {
|
||||
echo $args['before_title'] . apply_filters( 'widget_title', $instance['title'], $instance, $this->id_base ) . $args['after_title'];
|
||||
}
|
||||
|
||||
$image = '';
|
||||
$image_id = 'post' === $instance['post_type'] ? $postspage_image : displayfeaturedimagegenesis_check_image_id( $option['post_type'][ $post_type->name ] );
|
||||
$image = '';
|
||||
if ( isset( $option['post_type'][ $post_type->name ] ) ) {
|
||||
$image_id = displayfeaturedimagegenesis_check_image_id( $option['post_type'][ $post_type->name ] );
|
||||
}
|
||||
$image_src = wp_get_attachment_image_src( $image_id, $instance['image_size'] );
|
||||
if ( $image_src ) {
|
||||
$image = '<img src="' . $image_src[0] . '" alt="' . $title . '" />';
|
||||
|
||||
Reference in New Issue
Block a user