【问题标题】:How to make soundcloud oembed endpoint return an iframe with a height of 300?如何使 soundcloud oembed 端点返回高度为 300 的 iframe?
【发布时间】:2019-02-28 07:59:10
【问题描述】:

我用的是souncloud的oembed端点,默认高度是400,太大了。

我需要调整一下,我试过这个:

https://soundcloud.com/oembed?format=json&height=300&url=https://soundcloud.com/giorgiomartini

但这只会改变艺术品的高度,请注意 html 键(iframe)末尾的高度,在我返回的 json 上:

{
"version": 1,
"type": "rich",
"provider_name": "SoundCloud",
"provider_url": "http://soundcloud.com",
"height": 450,
"width": "100%",
"title": "Giorgio Martini",
"description": null,
"thumbnail_url": "http://i1.sndcdn.com/avatars-000336450748-qnkjy0-t500x500.jpg",
"html": "<iframe width=\"100%\" height=\"450\" scrolling=\"no\" frameborder=\"no\" src=\"https://w.soundcloud.com/player/?visual=true&url=https%3A%2F%2Fapi.soundcloud.com%2Fusers%2F1367858&show_artwork=true&height=300\"></iframe>",
"author_name": "Giorgio Martini",
"author_url": "https://soundcloud.com/giorgiomartini"
}

但我确实需要更改 iframe 本身的高度... oembeed 有办法做到这一点吗?

或者我是否必须对返回的响应进行某种字符串操作以将高度从 400 更改为 300?

谢谢

【问题讨论】:

  • maxheight=300 作为 URL 参数?
  • 是的,只是想通了...将其发布为答案并接受它...谢谢! :)

标签: soundcloud oembed


【解决方案1】:

根据documentation,有一个URL参数叫做maxheight——只要把它设置为300:

https://soundcloud.com/oembed?format=json&maxheight=300&url=https://soundcloud.com/giorgiomartini

【讨论】:

    【解决方案2】:

    我建议改用 CSS 来使视频 iframe 具有响应性,因此无论窗口大小,在任何设备上,它始终会填满其父容器。请参阅 Fluid Width Video 和 VideoWrapper 类。

    【讨论】:

    • 谢谢我仔细研究一下,我已将其他回复标记为正确,因为它确实回答了该特定问题,但您的观点很好,谢谢!
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-05-04
    • 1970-01-01
    • 2012-05-08
    相关资源
    最近更新 更多