@benbodhi – I came across this error when working on a site locally that didn’t have all the uploads synchronised (normally I just redirect/proxy any missing uploads to the production server via a rewrite rule).
Although I understand the need for the file to be present, I think at the very least, a missing file should be handled more gracefully. In the snippet you provided above, it doesn’t seem to handle a file that is simply missing. To do this, it should check if the file exists inside the bodhi_svgs_get_dimensions
function, where it tries to load the file as XML.
I haven’t had time to look for a proper solution but a start would be something like this in the first line of the bodhi_svgs_get_dimensions
function:
if (! is_file($svg) ) return (object) array( 'width' => 0 , 'height' => 0 );
Then at least it won’t try to load a non-existent file, leading to the fatal error when trying to access properties that are not set… If the file really doesn’t exist, it’s impossible to know the dimensions so that’s why I set width and height to zero. What do you think?
Get well soon ??