【问题标题】:Tranformer Rule for Slideshow in Facebook Instant Article not working?Facebook Instant Article 中幻灯片的转换器规则不起作用?
【发布时间】:2017-09-28 14:37:03
【问题描述】:

我正在使用Justified Gallery,我想将我的页面作为即时文章发布到 Facebook。当我浏览文档here 时,我发现我可以通过Transformer Rules 将图像转换为Slideshow。这是我的画廊代码:

<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"
        }
    }
}

当我导入规则时,似乎我的规则破坏了一切,我不能再发表我的文章,我在这里做错了什么?

【问题讨论】:

    标签: facebook-instant-articles


    【解决方案1】:

    所以经过几个小时的研究,我找到了适合我的代码的正确规则。问题是你必须使用外部标签作为选择器(在我的例子中是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"
            }
        }
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-01-17
      • 2018-06-22
      相关资源
      最近更新 更多