Here’s the solution i’ve found.
Adding
// Find the base URL
$baseUrl = get_bloginfo ( ‘siteurl’ );
// remove the base url and convert to relative path
$imageurl = str_replace($baseUrl, “”, $imageurl);
before the original code below
echo “<img src=\”{$imageurl}\” style=\””;
if ( !empty( $width ) && is_numeric( $width ) ) {
echo “max-width: {$width}px;”;
}
If you had other solutions don’t hesitate to share.