我正在使用合理的画廊,我想在Facebook上发布我的页面作为即时文章。当我在此处浏览文档时,我发现可以通过变压器规则将图像转换为幻灯片。这是我的画廊代码:
<div class="myExMul">
<a href="link_to_img" class="swipeboxImg">
<img src="link_to_img" alt="example_text" class="myExMulImg">
</a>
<a href="link_to_img2" class="swipeboxImg">
<img src="link_to_img2" alt="example_text2" class="myExMulImg">
</a>
<a href="link_to_img3" class="swipeboxImg">
<img src="link_to_img3" alt="example_text3" class="myExMulImg">
</a>
</div>
这是我的变压器规则:
{
"class": "SlideshowRule",
"selector": "div.myExMul",
},
{
"class": "SlideshowImageRule",
"selector": "img.myExMulImg",
"properties": {
"image.url": {
"type": "string",
"selector": "img.myExMulImg",
"attribute": "src"
},
"caption.title": {
"type": "string",
"selector": "img.myExMulImg",
"attribute": "alt"
}
}
}
当我导入规则时,我的规则似乎违反了一切,我无法再发表文章,我在这里做错了什么?
因此,经过几个小时的研究,我找到了适合我的代码的规则。问题是您必须使用外部标签作为选择器(在我的情况下是a
标签),而不是内部标签(img
)。
{
"class": "SlideshowRule",
"selector": "div.myExMul"
},
{
"class": "SlideshowImageRule",
"selector": "a.swipeboxImg",
"properties": {
"image.url": {
"type": "string",
"selector": "img",
"attribute": "src"
},
"caption.title": {
"type": "string",
"selector": "img",
"attribute": "alt"
}
}
}