mirror of
https://github.com/10h30/display-featured-image-genesis.git
synced 2026-07-11 18:46:03 +09:00
Fix image validation
This commit is contained in:
@@ -199,29 +199,6 @@ class Display_Featured_Image_Genesis_Taxonomies extends Display_Featured_Image_G
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* check if file type is image. updated to use WP function.
|
||||
* @return bool
|
||||
* @since 1.2.2
|
||||
* @since 2.5.0
|
||||
*/
|
||||
protected function is_valid_img_ext( $file ) {
|
||||
$valid = wp_check_filetype( $file );
|
||||
|
||||
return (bool) in_array( $valid['ext'], $this->allowed_file_types(), true );
|
||||
}
|
||||
|
||||
/**
|
||||
* Define the array of allowed image/file types.
|
||||
* @return array
|
||||
* @since 2.5.0
|
||||
*/
|
||||
protected function allowed_file_types() {
|
||||
$allowed = apply_filters( 'displayfeaturedimage_valid_img_types', array( 'jpg', 'jpeg', 'png', 'gif' ) );
|
||||
|
||||
return is_array( $allowed ) ? $allowed : explode( ',', $allowed );
|
||||
}
|
||||
|
||||
/**
|
||||
* Help tab for media screen
|
||||
*
|
||||
|
||||
@@ -336,6 +336,29 @@ class Display_Featured_Image_Genesis_Helper extends DisplayFeaturedImageGenesisG
|
||||
return $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* check if file type is image. updated to use WP function.
|
||||
* @return bool
|
||||
* @since 1.2.2
|
||||
* @since 2.5.0
|
||||
*/
|
||||
protected function is_valid_img_ext( $file ) {
|
||||
$valid = wp_check_filetype( $file );
|
||||
|
||||
return (bool) in_array( $valid['ext'], $this->allowed_file_types(), true );
|
||||
}
|
||||
|
||||
/**
|
||||
* Define the array of allowed image/file types.
|
||||
* @return array
|
||||
* @since 2.5.0
|
||||
*/
|
||||
protected function allowed_file_types() {
|
||||
$allowed = apply_filters( 'displayfeaturedimage_valid_img_types', array( 'jpg', 'jpeg', 'png', 'gif' ) );
|
||||
|
||||
return is_array( $allowed ) ? $allowed : explode( ',', $allowed );
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines if the user has permission to save the information from the submenu
|
||||
* page.
|
||||
|
||||
@@ -177,29 +177,6 @@ class Display_Featured_Image_Genesis_Settings_Validate extends Display_Featured_
|
||||
return $message;
|
||||
}
|
||||
|
||||
/**
|
||||
* check if file type is image. updated to use WP function.
|
||||
* @return bool
|
||||
* @since 1.2.2
|
||||
* @since 2.5.0
|
||||
*/
|
||||
protected function is_valid_img_ext( $file ) {
|
||||
$valid = wp_check_filetype( $file );
|
||||
|
||||
return (bool) in_array( $valid['ext'], $this->allowed_file_types(), true );
|
||||
}
|
||||
|
||||
/**
|
||||
* Define the array of allowed image/file types.
|
||||
* @return array
|
||||
* @since 2.5.0
|
||||
*/
|
||||
protected function allowed_file_types() {
|
||||
$allowed = apply_filters( 'displayfeaturedimage_valid_img_types', array( 'jpg', 'jpeg', 'png', 'gif' ) );
|
||||
|
||||
return is_array( $allowed ) ? $allowed : explode( ',', $allowed );
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a 1 or 0, for all truthy / falsy values.
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user