Skip to content

Instantly share code, notes, and snippets.

@dmtrmrv
Created January 18, 2017 06:40
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save dmtrmrv/9eaccd96f2f841f6120c25289c6cbe37 to your computer and use it in GitHub Desktop.
Save dmtrmrv/9eaccd96f2f841f6120c25289c6cbe37 to your computer and use it in GitHub Desktop.
Sanitize image upload in Customizer
<?php
/**
* Sanitizes Image Upload.
*
* @param string $input potentially dangerous data.
*/
function themepatio_sanitize_image( $input ) {
$filetype = wp_check_filetype( $input );
if ( $filetype['ext'] && wp_ext2type( $filetype['ext'] ) === 'image' ) {
return esc_url( $input );
}
return '';
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment