Skip to content

Instantly share code, notes, and snippets.

@vikastyagi87
Created August 15, 2020 11:50
Show Gist options
  • Save vikastyagi87/f8ea884d86d0dd992e5e8b39eaae57cc to your computer and use it in GitHub Desktop.
Save vikastyagi87/f8ea884d86d0dd992e5e8b39eaae57cc to your computer and use it in GitHub Desktop.
Illegal string offset ‘width’ and ‘height’ WordPress
//this issue occurs when using image uploaded SVGs
// Image widgets
function wp_get_attachment_metadata_mine($data) {
$res = $data;
if (!isset($data['width']) || !isset($data['height'])) {
$res = false;
}
return $res;
}
add_filter( 'wp_get_attachment_metadata' , 'wp_get_attachment_metadata_mine' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment