【问题标题】:WP-rest API response too bigWP-rest API 响应太大
【发布时间】:2017-11-24 04:41:33
【问题描述】:

当我调用 wp rest API 时,响应太大了大约 1.5 mb,这使得我的移动应用程序非常慢。如何确定 wp-rest API 应该返回哪些字段?

示例:
而不是得到

"tags": [],
    "better_featured_image": {
      "id": 13668,
      "alt_text": "",
      "caption": "Solicitud real ante la dificil situacion de los refugiados sirios bloqueados entre Argelia y Marruecos",
      "description": "",
      "media_type": "image",
      "media_details": {
        "width": 675,
        "height": 402,
        "file": "2017/06/sm-le-roi-ceremonie-mawlid-nabawi-g1-504x300_5.jpg",
        "sizes": {
          "thumbnail": {
            "file": "sm-le-roi-ceremonie-mawlid-nabawi-g1-504x300_5-150x89.jpg",
            "width": 150,
            "height": 89,
            "mime-type": "image/jpeg",
            "source_url": "http://infomarruecos.ma/wp-content/uploads/2017/06/sm-le-roi-ceremonie-mawlid-nabawi-g1-504x300_5-150x89.jpg"
          },
          "medium": {
            "file": "sm-le-roi-ceremonie-mawlid-nabawi-g1-504x300_5-300x179.jpg",
            "width": 300,
            "height": 179,
            "mime-type": "image/jpeg",
            "source_url": "http://infomarruecos.ma/wp-content/uploads/2017/06/sm-le-roi-ceremonie-mawlid-nabawi-g1-504x300_5-300x179.jpg"
          },
          "slgf_12_thumb": {
            "file": "sm-le-roi-ceremonie-mawlid-nabawi-g1-504x300_5-500x402.jpg",
            "width": 500,
            "height": 402,
            "mime-type": "image/jpeg",
            "source_url": "http://infomarruecos.ma/wp-content/uploads/2017/06/sm-le-roi-ceremonie-mawlid-nabawi-g1-504x300_5-500x402.jpg"
          },

只买中等大小的

"better_featured_image": {
      "id": 13668,
      "alt_text": "",
      "caption": "Solicitud real ante la dificil situacion de los refugiados sirios bloqueados entre Argelia y Marruecos",
      "description": "",
      "media_type": "image",
      "media_details": {
        "width": 675,
        "height": 402,
        "file": "2017/06/sm-le-roi-ceremonie-mawlid-nabawi-g1-504x300_5.jpg",
        "sizes": {
          "thumbnail": {
            "file": "sm-le-roi-ceremonie-mawlid-nabawi-g1-504x300_5-150x89.jpg",
            "width": 150,
            "height": 89,
            "mime-type": "image/jpeg",
            "source_url": "http://infomarruecos.ma/wp-content/uploads/2017/06/sm-le-roi-ceremonie-mawlid-nabawi-g1-504x300_5-150x89.jpg"
          },
          "medium": {
            "file": "sm-le-roi-ceremonie-mawlid-nabawi-g1-504x300_5-300x179.jpg",
            "width": 300,
            "height": 179,
            "mime-type": "image/jpeg",
            "source_url": "http://infomarruecos.ma/wp-content/uploads/2017/06/sm-le-roi-ceremonie-mawlid-nabawi-g1-504x300_5-300x179.jpg"
          },

【问题讨论】:

    标签: wordpress rest api


    【解决方案1】:

    我的主题是为响应性生成大量图像,因此其余 api ketp 发回所有可用图像。我会尝试添加自定义端点

    【讨论】:

      猜你喜欢
      • 2017-09-20
      • 2019-02-04
      • 1970-01-01
      • 1970-01-01
      • 2012-05-15
      • 1970-01-01
      • 1970-01-01
      • 2017-10-17
      • 1970-01-01
      相关资源
      最近更新 更多