使用WebP作为SVG中的背景图像

时间:2016-09-02 11:55:21

标签: html5 svg jpeg webp

所以我想在HTML中做同样的事情或类似的事情:

   <picture>
      <source type="image/webp" srcset="my-image.webp">
      <img src="my-image.jpg">
   </picture>

但是,显然这不起作用:

   <svg>
      <picture>
         <source type="image/webp" srcset="my-image.webp">
         <img src="my-image.jpg">
      </picture>
   </svg>

我可以使用.htaccess方法,但我不愿意,因为302 HTTP重定向。

该解决方案还需要在没有任何JavaScript技巧的情况下工作......

2 个答案:

答案 0 :(得分:0)

这是我最终要做的,感谢Robert Longson的意见:

9999

答案 1 :(得分:0)

                    if (RESULT == "SKIPPED") { 
                        colour = "#ffffb3" 
                        moremessage1 += "<br>test.getSkippedMessage():" + test.getSkippedMessage() + "</br>"
                        moremessage1 += "<br>test.getStatus().getMessage():" + test.getStatus().getMessage() + "</br>"
                        moremessage1 += "<br>test.getTitle():" + test.getTitle() + "</br>"
                        moremessage1 += "<br>test.getStdout():" + test.getStdout() + "</br>"
                        moremessage1 += "<br>test.getStderr():" + test.getStderr() + "</br>"
                        moremessage1 += "<br>test.getErrorDetails():" + test.getErrorDetails() + "</br>"
                        moremessage1 += "<br>test.getErrorStackTrace():" + test.getErrorStackTrace() + "</br>"
                        moremessage1 += "<br>test.getName():" + test.getName() + "</br>"
                        moremessage1 += "<br>test.getSafeName():" + test.getSafeName() + "</br>"
                        moremessage1 += "<br>test.getSimpleName():" + test.getSimpleName() + "</br>"
                        moremessage1 += "<br>test.getFullName():" + test.getFullName() + "</br>"
                        moremessage1 += "<br>test.getClassName():" + test.getClassName() + "</br>"
                        moremessage1 += "<br>test.getDisplayName():" + test.getDisplayName() + "</br>"
                        moremessage1 += "<br>test.getPackageName():" + test.getPackageName() + "</br>"

mozilla文档:https://developer.mozilla.org/en-US/docs/Web/SVG/Element/image

Does SVG support embedding of bitmap images?重复