当使用rss feed.I时,如何在simplepie中只显示图像?我正在使用simplepie,但允许从rss.How中仅提取图像来执行此操作?
发布于 2012-06-20 23:48:01
也许你想在客户端做这件事。然后,使用jQuery就很容易了。假设javascript中的item-content如下所示
var content = '<div><a href="http://kwout.com/cutout/b/es/y2/ukn_rou_sha.jpg"
imageanchor="1" style="clear: right; float: right; margin-bottom: 1em; margin-left: 1em;">
<img border="0" height="239" src="http://kwout.com/cutout/b/es/y2/ukn_rou_sha.jpg"
width="320"></a>Erat austro rerum.</div>';然后,您可以使用jQuery选择器轻松地识别和隔离内容中的图像。例如,使用
$(content).find('img:first'); //find the FIRST image inside an element or
$(content).find('a:first'); //take the hyperlink AND the image如果它不是内容中的第一个图像,或者内容比这个例子更复杂(主要是;-) -不用担心-那么其他一些选择器就可以解决这个问题。有关更多信息,请查看jquery.com上的文档。
通过这种方式,我删除了一些元素,在内容中添加了一些或添加了一些类,以便以我的方式显示帖子。
https://stackoverflow.com/questions/10577746
复制相似问题