WordPress sanitize image upload

Published
May 14, 2022
浏览次数 :  0

/**
 * Check Image
 * @since 0.1.0
 */
function my_sanitize_image( $input ){
 
    /* default output */
    $output = '';
 
    /* check file type */
    $filetype = wp_check_filetype( $input );
    $mime_type = $filetype['type'];
 
    /* only mime type "image" allowed */
    if ( strpos( $mime_type, 'image' ) !== false ){
        $output = $input;
    }
 
    return $output
}

Top