How to fetch images from response of themoviedb api

15.1k Views Asked by At

I'm getting the following JSON response from themoviedb API:

{
         "popularity":1640.159,
         "vote_count":32,
         "video":false,
         "poster_path":"\/9Rj8l6gElLpRL7Kj17iZhrT5Zuw.jpg",
         "id":734309,
         "adult":false,
         "backdrop_path":"\/7fvdg211A2L0mHddvzyArRuRalp.jpg",
         "original_language":"en",
         "original_title":"Santana",
         "genre_ids":[
            28
         ],
         "title":"Santana",
         "vote_average":6.3,
         "overview":"Two brothers — one a narcotics agent and the other a general — finally discover the identity of the drug lord who murdered their parents decades ago. They may kill each other before capturing the bad guys.",
         "release_date":"2020-08-28"
      }

I have to use poster_path but I'm unable to understand it as it's just the image name but not any path. I've no idea how can I get the image from this poster_path string.

Please help me! When I paste the url on Google I got nothing.

2

There are 2 best solutions below

0
On

You can Use glide library to fetch and display image from the server. check below URL.
-- https://bumptech.github.io/glide/ contains how to use glide.

 Glide
        .with(may be context)
        .load(url)
        .into(your Image View);
2
On

As per the the movie db doc, it's in the following format:-

http://image.tmdb.org/t/p/w500/your_poster_path

(Taking poster path from your question, now you can see image by pasting this in browser as URL - http://image.tmdb.org/t/p/w500/9Rj8l6gElLpRL7Kj17iZhrT5Zuw.jpg )

Either use Glide or picasso to show it by following other answers.