One more thing – I think the basic idea of the change I made is correct, however it’s unclear to me whether to use $response['url'] or one of the attributes on the $attachment-object — e.g. get_attachment_link( $attachment->ID ) (I don’t know a lot about WordPress internals).
(Note to self: https://wpseek.com/function/wp_prepare_attachment_for_js/ – the filter is called from here, so here almost all the $attachment-attributes are listed)
P.S. Hope everything went well with the surgery, and that you’re feeling OK 🙂
I had the same problem when using uploaded files on an external server.
To fix it I made the following addition to functions/attachment-modal.php (line 13-19 shown below):
$svg_path = get_attached_file( $attachment->ID );
if ( ! file_exists( $svg_path ) ) {
// In the case where the SVG is located on an external URL
// (not on this server), we use the URL instead of the path
$svg_path = $response[ 'url' ];
}
$dimensions = bodhi_svgs_get_dimensions( $svg_path );
Highlighted diff: https://gist.github.com/malthejorgensen/4ec565f444c969731c71089afd70cbde/revisions