Fix image validation

This commit is contained in:
Robin Cornett
2017-11-02 12:46:44 -04:00
parent bad07bd655
commit bca243f9cc
3 changed files with 23 additions and 46 deletions
@@ -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.
*