2014-09-22 109 views
1

我正在將圖像嵌入到我的電子郵件中,因此我使用聯機工具對其進行了編碼。如何將路徑添加到base64編碼圖像

問題是我的電子郵件模板使用動態url,即$ {loginurl}/images作爲我的圖像的路徑。

如何將該動態路徑追加到我的圖像?我在下面嘗試,但圖像仍然不顯示在電子郵件中。

<img src="data:image/png;base64,${loginurl}/images/iVBORw0KGgoAAAANSUhEUgAAAKMAAAA7CAYAAAAXWTquAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAB7hJREFUeNrsXU1u4zYUpo3s655g5BOM0wN0lF4g9rooRlp0UaBF7FW7s71rV3bQAl10YQVF1/FcoFZ6gMY9wWhOMLqByxc/JvQLKZP6yST2+wDCkSyK9NOn98cnRQgGg8FgMBgMBoPBYDAYDMYLRYtFUA/++ueXify4kG369Zc/zi3fj2Ubmb5nCNFmEdSG17J18NP2PeANi4rRtGbsyBbuOSZkSTEY7DMeNn5efjtBs3vzU/+PiWMfMOVD7Hcl+yUsSSZjVSKCyV1pu2IXYsl+QMSZtutU9luzRDmAqYKMbK9L9MuxMVgzVtaOgfyAlkntlnn062Hk7dWPwWCwZnx++CH5CrRghKY1+TX6u7KJ/X4Rwjn7uLn8LU4zJiNjHxFpwAJE7FYhJBLxFk22OufpsRKSAxh3hGQbCNSreM5II6I6Z8TRNGMfaLScGyJqXySGaHrJZprhaqqVhgSfsbI5RVOttGFyKCZ6s9mYLIdKZcFvXrdarbzgWAajNjL2ZFvJdivbR/x7Jttks0WkHbuAHawZ9+Cb378ATZj9+d2/WYULE6A2yKU2WDuMqY5fy3HzF05KkN9Y/u4z3J7Ij/M7s9xqneK+jyDj1hHdqSEJQhIpjKyAEHDnzrQAI5Vt4EoOJCDUL/ZJkCLQ11zK8UdkTDhuIR5SPYC5HHN0YGQEvAV5onmGdfrgmAKYEMmhWrBHMy0IiULc52SixDZlExmIKHDsniW67pN9Qzmf/gFejyuxLUZ+i39zNG2Bjagdx/5jw7Fr1K5FZ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I9rsGxnx3BGR0vYFNZnPc4Lyc5P6p1qaDPZPllyGVw4c6yfHUsC0HDhomBJPteQF8vKvnSsa8hnVdH9wQvyJgfjypb/nU17vQTN98YjVOfZ0mXsJ+zhy0yvtZPPClyLgsE4q7AosuiiIqOn5E0z8Vxw8Fv7FAzy6sCSGDOivfsegiKkVGnFzaRJiPpIJMv3q7QN8gnFw8zk0tapT/jCn4CNMmZITLf3C9F/gmiZnrkmC7YHLjMuw2EHFFzH+vQDh6YNPDoo2qwilTAncM2jEhvmMt8ha7JYdAwtA1md7WJpcaCLnAZaNSphmJqN8VqW0BH5PcscFcl6pJ1OrzIqaeFaZilmuf4gYi71vif+bCYyWtTQgxMZjLGRIidCUhkuCaEBHuwsGeu3VpmDyMe4tP93UchQK/gxaY8n8UMPuONI0HZHrvahVR3jOUN300wauE7MQwwVieHE40JIQIsbzcVFwL378S5vfKqAAldixJSnAcnczqGWZwHVKM/vXi2gDbuTAn0GPR/KrSSyUkLJWeESumyr9meO0+0JhCPBRT9yzR+sD32ZgTywRHciLv0P4HZBI+ZhsmNfJYvNcF1EWnOjJoStfIL8Hx8zqj80PUkBZ562/SdV0uhMKYUkUX7SJCyNZFreJbE6g0YdeXiHqEjSVkXfyBmccNAMfD2HFTTyoeICF1eSfCb5Usw3gDZD4qK3Ov15to+TqTKc7RdK4bfFRVmdrAIpDaHptk7FT32KyKut4ZS4vBYDAYDAaD8RT4X4ABAPDRuBQZDmtXAAAAAElFTkSuQmCC" /> 

這裏是如何的圖像顯示在我的郵箱:

enter image description here

+0

定義「它不工作」 – Scott 2014-09-22 16:09:34

+1

當你提供一個數據url,它*沒有一個路徑*。事實上,你的電子郵件模板**期望**文件路徑是這裏的問題。你不會通過玩'src'屬性來解決這個問題。 – spender 2014-09-22 16:09:45

+1

我已經從我的圖像中刪除了文件路徑,現在只是使用數據url;它仍然不起作用,但可能是因爲電子郵件的MIME類型。 – fumeng 2014-09-22 17:14:51

回答

1

當使用在base64編碼的圖像數據的協議,它沒有一個域或URL或路徑。

例如,如果您將數據網址複製到Chrome中,它將直接顯示圖像,而不會伸出Internet以下載它。

試試:

data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAKMAAAA7CAYAAAAXWTquAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAB7hJREFUeNrsXU1u4zYUpo3s655g5BOM0wN0lF4g9rooRlp0UaBF7FW7s71rV3bQAl10YQVF1/FcoFZ6gMY9wWhOMLqByxc/JvQLKZP6yST2+wDCkSyK9NOn98cnRQgGg8FgMBgMBoPBYDAYDMYLRYtFUA/++ueXify4kG369Zc/zi3fj2Ubmb5nCNFmEdSG17J18NP2PeANi4rRtGbsyBbuOSZkSTEY7DMeNn5efjtBs3vzU/+PiWMfMOVD7Hcl+yUsSSZjVSKCyV1pu2IXYsl+QMSZtutU9luzRDmAqYKMbK9L9MuxMVgzVtaOgfyAlkntlnn062Hk7dWPwWCwZnx++CH5CrRghKY1+TX6u7KJ/X4Rwjn7uLn8LU4zJiNjHxFpwAJE7FYhJBLxFk22OufpsRKSAxh3hGQbCNSreM5II6I6Z8TRNGMfaLScGyJqXySGaHrJZprhaqqVhgSfsbI5RVOttGFyKCZ6s9mYLIdKZcFvXrdarbzgWAajNjL2ZFvJdivbR/x7Jttks0WkHbuAHawZ9+Cb378ATZj9+d2/WYULE6A2yKU2WDuMqY5fy3HzF05KkN9Y/u4z3J7Ij/M7s9xqneK+jyDj1hHdqSEJQhIpjKyAEHDnzrQAI5Vt4EoOJCDUL/ZJkCLQ11zK8UdkTDhuIR5SPYC5HHN0YGQEvAV5onmGdfrgmAKYEMmhWrBHMy0IiULc52SixDZlExmIKHDsniW67pN9Qzmf/gFejyuxLUZ+i39zNG2Bjagdx/5jw7Fr1K5FZrrjOZ+XjARvvEBqzZTJaIE0izbSXHloYR1n4B+BqUI/6XPZpoZ+qWEfuAUHl+5BFwl+7+X9viPyGSeosXSCpAWmuoPH95AQV5KkS8exNjrBlL/kETC9RW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hy0yvtZPPClyLgsE4q7AosuiiIqOn5E0z8Vxw8Fv7FAzy6sCSGDOivfsegiKkVGnFzaRJiPpIJMv3q7QN8gnFw8zk0tapT/jCn4CNMmZITLf3C9F/gmiZnrkmC7YHLjMuw2EHFFzH+vQDh6YNPDoo2qwilTAncM2jEhvmMt8ha7JYdAwtA1md7WJpcaCLnAZaNSphmJqN8VqW0BH5PcscFcl6pJ1OrzIqaeFaZilmuf4gYi71vif+bCYyWtTQgxMZjLGRIidCUhkuCaEBHuwsGeu3VpmDyMe4tP93UchQK/gxaY8n8UMPuONI0HZHrvahVR3jOUN300wauE7MQwwVieHE40JIQIsbzcVFwL378S5vfKqAAldixJSnAcnczqGWZwHVKM/vXi2gDbuTAn0GPR/KrSSyUkLJWeESumyr9meO0+0JhCPBRT9yzR+sD32ZgTywRHciLv0P4HZBI+ZhsmNfJYvNcF1EWnOjJoStfIL8Hx8zqj80PUkBZ562/SdV0uhMKYUkUX7SJCyNZFreJbE6g0YdeXiHqEjSVkXfyBmccNAMfD2HFTTyoeICF1eSfCb5Usw3gDZD4qK3Ov15to+TqTKc7RdK4bfFRVmdrAIpDaHptk7FT32KyKut4ZS4vBYDAYDAaD8RT4X4ABAPDRuBQZDmtXAAAAAElFTkSuQmCC 

如果你想創建自己的數據網址的形象,也有大量的免費在線工具像這樣的:http://dataurl.net/#dataurlmaker

+1

感謝您的解釋。我使用上述工具創建了一個數據URL圖像。它仍然不會顯示在我的電子郵件中,但是將該URL複製並粘貼到瀏覽器中會顯示它。我認爲缺失的部分可能是將我的電子郵件定義爲多部分MIME信息。 – fumeng 2014-09-22 17:13:34

+0

如果您將HTML看作純文本,那聽起來很對。查看收到的電子郵件的原始來源,瞭解如何收到該圖片標記。也許有一個編碼問題。 – Scott 2014-09-22 17:51:21

相關問題