function replaceImageMeta( $imagename ) {
preg_match_all('/(alt|title|src)=("[^"]*")/i',$imagename, $img);//var_dump( str_replace("\"", "" , ( $img[2][0] ) ) );
list($width, $height, $type, $attr) = getimagesize( str_replace("\"", "" , ( $img[2][0] ) ));
$imgname = str_replace("\"", "" , ( $img[2][0] ) );
return sprintf('<img'<img src="%s" width="%dpx" height="%dpx" >', str_replace("\"", "" , ( $img[2][0] ) ), $width, $height);
}
So call the function with image string
replaceImageMeta( "<img"<img src=\"https://link.to/sum/img.jpg\" alt=\"Image Title\">"Title\" >" )