diff --git a/src/core/service/api/media/get-image-info.js b/src/core/service/api/media/get-image-info.js index c62d1b031deeda38c0bbec95a218263097919c3b..d8e2ed9f897a43dbd842f1cf41a9ff93de4c645f 100644 --- a/src/core/service/api/media/get-image-info.js +++ b/src/core/service/api/media/get-image-info.js @@ -1,3 +1,9 @@ +import getRealPath from 'uni-platform/helpers/get-real-path' + +function _getServiceAddress () { + return window.location.protocol + '//' + window.location.host +} + export function getImageInfo ({ src }, callbackId) { @@ -5,11 +11,13 @@ export function getImageInfo ({ invokeCallbackHandler: invoke } = UniServiceJSBridge const img = new Image() + const realPath = getRealPath(src) img.onload = function () { invoke(callbackId, { errMsg: 'getImageInfo:ok', width: img.naturalWidth, - height: img.naturalHeight + height: img.naturalHeight, + path: realPath.indexOf('/') === 0 ? _getServiceAddress() + realPath : realPath }) } img.onerror = function (e) { @@ -18,4 +26,5 @@ export function getImageInfo ({ }) } img.src = src + console.log(img) }