I didn’t get that quite right. it USED to fallback to the guid, but the code in wp_get_attachment_url currently does this
if ( 0 === strpos($file, $uploads['basedir']) ) //Check that the upload base exists in the file location
$url = str_replace($uploads['basedir'], $uploads['baseurl'], $file); //replace file location with url location
elseif ( false !== strpos($file, 'wp-content/uploads') )
$url = $uploads['baseurl'] . substr( $file, strpos($file, 'wp-content/uploads') + 18 );
else
$url = $uploads['baseurl'] . "/$file"; //Its a newly uploaded file, therefor $file is relative to the basedir.
which translates as
if the /path/to/wordpress/wp-content/uploads path is in the file path, then it replace that path with https://yrdomain.com/wordpress/wp-content/uploads
OTHERWISE
if you can find “content/uploads” anywhere in the filepath replace text up to that with https://yrdomain.com/wordpress/wp-content/uploads
OTHERWISE
just put https://yrdomain.com/wordpress/wp-content/uploads/ on the start of the filepath (probably as this is the old relative to uploads filepath WP *used* to do)
which means it will not fall back on the guid (which the plugin does rewire correctly!). I’d rather it didn’t use that final otherwise and instead did fail back to the guid, as it means, you can no longer have media items outside of the uploads path! my plugin is violating that assumption, so I’m not going to raise a ticket to get that assumption changed. instead i’ll work out the proper wp_get_attachment_url filter function to use (as shown for the specific case above)