mirror of
https://github.com/10h30/display-featured-image-genesis.git
synced 2026-06-05 15:08:20 +09:00
change how images are assigned
This commit is contained in:
@@ -67,31 +67,32 @@ class Display_Featured_Image_Genesis_Common {
|
||||
$image_id = $item->fallback_id;
|
||||
}
|
||||
|
||||
$object = get_queried_object();
|
||||
// if it's a home page with a static front page, and there is a featured image set on the home page
|
||||
// outlier: if it's a home page with a static front page, and there is a featured image set on the home page
|
||||
if ( is_home() && 'page' === $frontpage && ! empty( $postspage_image ) ) {
|
||||
$image_id = $postspage_image;
|
||||
}
|
||||
|
||||
elseif ( is_post_type_archive() ) {
|
||||
$post_type = $object->name;
|
||||
$object = get_queried_object();
|
||||
if ( ! is_author() && ! is_admin() ) {
|
||||
if ( $object->name ) { // results in post type on cpt archive
|
||||
$post_type = $object->name;
|
||||
}
|
||||
elseif ( $object->taxonomy ) { // on a tax/term/category
|
||||
$tax_object = get_taxonomy( $object->taxonomy );
|
||||
$post_type = $tax_object->object_type[0];
|
||||
}
|
||||
elseif ( $object->post_type ) { // on singular
|
||||
$post_type = $object->post_type;
|
||||
}
|
||||
if ( ! empty( $displaysetting['post_type'][$post_type] ) ) {
|
||||
$image_id = self::get_image_id( $displaysetting['post_type'][$post_type] );
|
||||
}
|
||||
}
|
||||
// taxonomy
|
||||
elseif ( is_category() || is_tag() || is_tax() ) {
|
||||
if ( is_category() || is_tag() || is_tax() ) {
|
||||
$t_id = $object->term_id;
|
||||
$term_meta = get_option( "displayfeaturedimagegenesis_$t_id" );
|
||||
// if there is a post type image, set that first, as a fallback
|
||||
if ( $object->taxonomy ) {
|
||||
$tax_object = get_taxonomy( $object->taxonomy );
|
||||
$post_type = $tax_object->object_type[0];
|
||||
if ( ! empty( $displaysetting['post_type'][$post_type] ) ) {
|
||||
$image_id = self::get_image_id( $displaysetting['post_type'][$post_type] );
|
||||
}
|
||||
}
|
||||
// if there is a term image, use that instead
|
||||
// if there is a term image
|
||||
if ( ! empty( $term_meta['term_image'] ) ) {
|
||||
$image_id = self::get_image_id( $term_meta['term_image'] );
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user