Skip to main content
deleted 5 characters in body
Source Link
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('&lt;img'<img src="%s" width="%dpx" height="%dpx" >', str_replace("\"", "" , ( $img[2][0] ) ), $width, $height);

}

So call the function with image string

replaceImageMeta( "&lt;img"<img src=\"https://link.to/sum/img.jpg\" alt=\"Image Title\"&gt;"Title\" >" )
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('&lt;img src="%s" width="%dpx" height="%dpx" >', str_replace("\"", "" , ( $img[2][0] ) ), $width, $height);

}

So call the function with image string

replaceImageMeta( "&lt;img src=\"https://link.to/sum/img.jpg\" alt=\"Image Title\"&gt;" )
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 src="%s" width="%dpx" height="%dpx" >', str_replace("\"", "" , ( $img[2][0] ) ), $width, $height);

}

So call the function with image string

replaceImageMeta( "<img src=\"https://link.to/sum/img.jpg\" alt=\"Image Title\" >" )
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 src="%s" width="%dpx" height="%dpx" >', str_replace(""", "" , ( $img[2][0] ) ), $width, $height);

}

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('&lt;img src="%s" width="%dpx" height="%dpx" >', str_replace("\"", "" , ( $img[2][0] ) ), $width, $height);

}

So call the function with image string replaceImageMeta( "<img src="https://link.to/sum/img.jpg" alt="Image Title">" )

replaceImageMeta( "&lt;img src=\"https://link.to/sum/img.jpg\" alt=\"Image Title\"&gt;" )
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 src="%s" width="%dpx" height="%dpx" >', str_replace(""", "" , ( $img[2][0] ) ), $width, $height);

}

So call the function with image string replaceImageMeta( "<img src="https://link.to/sum/img.jpg" alt="Image Title">" )

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('&lt;img src="%s" width="%dpx" height="%dpx" >', str_replace("\"", "" , ( $img[2][0] ) ), $width, $height);

}

So call the function with image string

replaceImageMeta( "&lt;img src=\"https://link.to/sum/img.jpg\" alt=\"Image Title\"&gt;" )
Source Link

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 src="%s" width="%dpx" height="%dpx" >', str_replace(""", "" , ( $img[2][0] ) ), $width, $height);

}

So call the function with image string replaceImageMeta( "<img src="https://link.to/sum/img.jpg" alt="Image Title">" )