mirror of
https://github.com/10h30/display-featured-image-genesis.git
synced 2026-07-17 13:33:32 +09:00
Add backwards compatibility check helper function
This commit is contained in:
@@ -15,9 +15,8 @@
|
||||
*
|
||||
* @since 2.1.0
|
||||
*/
|
||||
function display_featured_image_genesis_get_term_image_id() {
|
||||
function display_featured_image_genesis_get_term_image_id( $image_id = '' ) {
|
||||
|
||||
$image_id = '';
|
||||
$taxonomies = get_taxonomies();
|
||||
$args = array( 'orderby' => 'count', 'order' => 'DESC' );
|
||||
$terms = wp_get_object_terms( get_the_ID(), $taxonomies, $args );
|
||||
@@ -26,12 +25,12 @@ function display_featured_image_genesis_get_term_image_id() {
|
||||
$t_id = $term->term_id;
|
||||
$term_meta = get_option( "displayfeaturedimagegenesis_$t_id" );
|
||||
if ( ! empty( $term_meta['term_image'] ) ) {
|
||||
$image_id = is_numeric( $term_meta['term_image'] ) ? $term_meta['term_image'] : Display_Featured_Image_Genesis_Common::get_image_id( $term_meta['term_image'] );
|
||||
$image_id = displayfeaturedimagegenesis_check_image_id( $term_meta['term_image'] );
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return absint( $image_id );
|
||||
return (int) $image_id;
|
||||
|
||||
}
|
||||
|
||||
@@ -57,14 +56,13 @@ function display_featured_image_genesis_get_term_image_url( $size = 'displayfeat
|
||||
*
|
||||
* @since 2.1.0
|
||||
*/
|
||||
function display_featured_image_genesis_get_default_image_id() {
|
||||
function display_featured_image_genesis_get_default_image_id( $image_id = '' ) {
|
||||
|
||||
$image_id = '';
|
||||
$displaysetting = get_option( 'displayfeaturedimagegenesis' );
|
||||
$fallback = $displaysetting['default'];
|
||||
$image_id = is_numeric( $fallback ) ? $fallback : Display_Featured_Image_Genesis_Common::get_image_id( $fallback );
|
||||
$image_id = displayfeaturedimagegenesis_check_image_id( $fallback );
|
||||
|
||||
return absint( $image_id );
|
||||
return (int) $image_id;
|
||||
|
||||
}
|
||||
|
||||
@@ -90,9 +88,9 @@ function display_featured_image_genesis_get_default_image_url( $size = 'displayf
|
||||
*
|
||||
* @since 2.1.0
|
||||
*/
|
||||
function display_featured_image_genesis_get_cpt_image_id() {
|
||||
function display_featured_image_genesis_get_cpt_image_id( $image_id = '' ) {
|
||||
|
||||
$image_id = $post_type = '';
|
||||
$post_type = '';
|
||||
$displaysetting = get_option( 'displayfeaturedimagegenesis' );
|
||||
$object = get_queried_object();
|
||||
if ( ! $object || is_admin() ) {
|
||||
@@ -107,10 +105,10 @@ function display_featured_image_genesis_get_cpt_image_id() {
|
||||
$post_type = $object->post_type;
|
||||
}
|
||||
if ( ! empty( $displaysetting['post_type'][ $post_type ] ) ) {
|
||||
$image_id = is_numeric( $displaysetting['post_type'][ $post_type ] ) ? $displaysetting['post_type'][ $post_type ] : Display_Featured_Image_Genesis_Common::get_image_id( $displaysetting['post_type'][ $post_type ] );
|
||||
$image_id = displayfeaturedimagegenesis_check_image_id( $displaysetting['post_type'][ $post_type ] );
|
||||
}
|
||||
|
||||
return absint( $image_id );
|
||||
return (int) $image_id;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -186,3 +184,15 @@ function display_featured_image_genesis_add_archive_thumbnails() {
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* function to check image_id value, convert from URL if necessary
|
||||
* @param string $image_id int or URL string
|
||||
* @return int image ID
|
||||
*
|
||||
* @since 2.3.0
|
||||
*/
|
||||
function displayfeaturedimagegenesis_check_image_id( $image_id = '' ) {
|
||||
$image_id = is_numeric( $image_id ) ? $image_id : Display_Featured_Image_Genesis_Common::get_image_id( $image_id );
|
||||
return $image_id;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user