熊掌号改造中对图片数量的要求要么是一张要么是三张,这里采用函数判断就显得相对轻松了代码运行结果如下:
源代码【实际运用直接改成自己相关的配置信息即可】:
<scripttype="application/ld+json">{ "@context":"https://zhanzhang.baidu.com/contexts/cambrian.jsonld", "@id":"https://blog.weguiding.com{dede:fieldname='arcurl'/}", "appid":"1587107621134358", "title":"{dede:field.title/}", "images":[{dede:field.bodyrunphp='yes'}$str=strip_tags("@me"," <img/>"); preg_match_all("/src="?(.*?)"/",$str,$ereg); $urlarr=$ereg[1]; if(count($urlarr)>=3){@me='"'.$urlarr[0].'","'.$urlarr[1].'","'.$urlarr[2].'"';} else{@me='"'.$urlarr[0].'"';}{/dede:field.body}], "description":"{dede:fieldname='description'function='html2text(@me)'/}", "pubDate":"{dede:fieldname='pubdate'function='strftime("%Y-%m-%dT%H:%M:%S","@me")'/}"} </script>