Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save champsupertramp/9aead89e6201f6de61582ef485545b95 to your computer and use it in GitHub Desktop.
Save champsupertramp/9aead89e6201f6de61582ef485545b95 to your computer and use it in GitHub Desktop.
Ultimate Member - Support WebP in the Image Uploader
<?php
// Cover & Profile Photo
add_filter("um_get_field__cover_photo","um_010223_allowed_webp_image_type", 10, 1 );
add_filter("um_get_field__profile_photo","um_010223_allowed_webp_image_type", 10, 1 );
function um_010223_allowed_webp_image_type( $data ){
$arr = explode( ",", $data['allowed_types'] );
$arr[ ] = "webp";
$data['allowed_types'] = implode(",", $arr);
return $data;
}
// User Photos extension
add_filter("um_user_photos_allowed_image_types","um_user_photos_010223_allowed_webp_image_type", 10, 1);
function um_user_photos_010223_allowed_webp_image_type( $arr_types ){
$arr_types[ ] = "image/webp";
return $arr_types;
}
// Social Activity & Groups discussions
add_filter("um_social_activity_allowed_image_types","um_010223_social_activty_allowed_webp_image_type", 10, 1 );
add_filter("um_groups_discussion_allowed_image_types","um_010223_social_activty_allowed_webp_image_type", 10, 1 );
function um_010223_social_activty_allowed_webp_image_type( $types ){
$types[ ] = "webp";
return $types;
}
// Core default image types
add_filter("um_uploader_image_default_filetypes","um_010223_activity_webp_image_type",10,1);
function um_010223_activity_webp_image_type( $types ){
$types[ ] = "WEBP";
return $types;
}
add_filter("um_allowed_image_types","um_010223_default_allowed_image_types");
function um_010223_default_allowed_image_types( $types ){
$types['webp'] = 'WEBP';
return $types;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment