Upload vCard files to WordPress

We use the upload_mimes Hook to add the vcard file formats to our allowed mime types. This can be placed in your custom or child themes functions.php file or in a custom plugin.

// Enable vcard upload
function enable_vcard_upload( $mime_types=array() ){
	$mime_types['vcf'] = 'text/vcard';
	$mime_types['vcard'] = 'text/vcard';
	return $mime_types;
add_filter('upload_mimes', 'enable_vcard_upload' );

You can craft this function to allow other file formats also, but be careful as you may be opening your site up to security holes. For file types like SVG I recommend the Safe SVG plugin.

Examples of vCards can be found here. These include formats not included in the code example above.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.