是否可以通过src
函数将src
属性的值更改为另一个值,并将原始data-src
值属性插入新的the_post_thumbnail()
属性中?
明白了吗?我要更改
<img src="img url">
到
<img src="another image" data-src="img url">
谢谢
答案 0 :(得分:1)
对于属性
仔细阅读wordpress文档。
https://developer.wordpress.org/reference/functions/the_post_thumbnail
the_post_thumbnail(string | array $ size ='post-thumbnail',string | array $ attr ='')
the_post_thumbnail( $size, $attr );
您可以使用jquery更改图片网址。
$(document).ready(function(){
$("#dummyimage").attr("src","http://via.placeholder.com/350x150");
});
<script
src="https://code.jquery.com/jquery-1.12.4.js"
integrity="sha256-Qw82+bXyGq6MydymqBxNPYTaUXXq7c8v3CwiYwLLNXU="
crossorigin="anonymous"></script>
<img id="dummyimage" src="http://via.placeholder.com/550x350" data-src="img url" />