Search code examples
soundcloudoembed

How to make soundcloud oembed endpoint return an iframe with a height of 300?


I am using souncloud's oembed endpoint, and the default height is 400, which is too big.

I need to adjust it, i have tried this:

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

But that only changes the height of the artwork, notice height at the end of the html key (the iframe), on the json i get back:

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

I do need however to change the height of the iframe itself... is there a waywith oembeed to do this?

Or do i have to do some kind of string manipulation on the response i get back to change the height from 400 to say 300?

Thanks


Solution

  • According to the documentation, there is an URL parameter called maxheight - simply set this to 300:

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