lib/utils/image.rb in metanorma-utils-1.4.4.1 vs lib/utils/image.rb in metanorma-utils-1.4.4.2

- old
+ new

@@ -125,15 +125,17 @@ # sources/plantuml/plantuml20200524-90467-1iqek5i.png # already includes localdir # Check whether just the local path or the other specified relative path # works. def datauri(uri, local_dir = ".") - return uri if datauri?(uri) || url?(uri) || absolute_path?(uri) + return uri if datauri?(uri) || url?(uri) - path = [uri, File.join(local_dir, uri)].detect do |p| +options = absolute_path?(uri) ? [uri] : [uri, File.join(local_dir, uri)] + path = options.detect do |p| File.exist?(p) ? p : nil end - unless path && File.exist?(path) + + unless path warn "Image specified at `#{uri}` does not exist." return uri # Return original provided location end encode_datauri(path)