Helix: Defining thumbnail width/height

The json response for thumbnail is:

https://static-cdn.jtvnw.net/previews-ttv/live_user_username-{width}x{height}.jpg

-However, this results in a broken image when trying to output it to html. How can I access the width and height properties of the given URL in a response object?

Substitute {width} and {height} for whatever you want

https://static-cdn.jtvnw.net/previews-ttv/live_user_username-200x200.jpg

For example

1 Like

I am generating these dynamically, is there anyway I can do it during the request or response?

Just string replace with {width} and the {height} with the width and height you want.

Fetch https://api.twitch.tv/helix/streams?user_login=cohhcarnage

Response is

“thumbnail_url”: “https://static-cdn.jtvnw.net/previews-ttv/live_user_cohhcarnage-{width}x{height}.jpg

I want a 400x200 so I take thumbnail_url and replace {width} with 400 and {height} by 200

Results in:

https://static-cdn.jtvnw.net/previews-ttv/live_user_cohhcarnage-400x200.jpg

Done

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.