WordPress sanitize image upload

Published
2022-05-14
浏览次数 :  161

/**
 * 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
}

  • 标签1
  • 标签1
  • 标签1
Top