The Movie Database Support

How do I access the backdrop image in a foreach statement

foreach ($search as $result) {  
    $movies[] = [
        'title' => $result->getTitle(),
        'image' => $result->getPoster(),
        'backdrop'=> $result->_data['backdrop'] // doesn't work because it's private
    ];
}

1 reply (on page 1 of 1)

Jump to last post

Hi @kirkdm When you say "private" it sounds like you're talking about the method in whatever language you are using. And if I was to guess, you're using a library of a sort? If so, you should contact the developer of the library.

The backdrop is just a field like any other, the backdrop_path field.

https://api.themoviedb.org/3/search/movie?api_key=###&query=inception

And looking at the first result...

{
  "poster_path": "/qmDpIHrmpJINaRKAfWQfftjCdyi.jpg",
  "adult": false,
  "overview": "Cobb, a skilled thief who commits corporate espionage by infiltrating the subconscious of his targets is offered a chance to regain his old life as payment for a task considered to be impossible: \"inception\", the implantation of another person's idea into a target's subconscious.",
  "release_date": "2010-07-14",
  "genre_ids": [
    28,
    53,
    878,
    9648,
    12
  ],
  "id": 27205,
  "original_title": "Inception",
  "original_language": "en",
  "title": "Inception",
  "backdrop_path": "/s2bT29y0ngXxxu2IA8AOzzXTRhd.jpg",
  "popularity": 8.313062,
  "vote_count": 9924,
  "video": false,
  "vote_average": 8
}

Can't find a movie or TV show? Login to create it.

Global

s focus the search bar
p open profile menu
esc close an open window
? open keyboard shortcut window

On media pages

b go back (or to parent when applicable)
e go to edit page

On TV season pages

(right arrow) go to next season
(left arrow) go to previous season

On TV episode pages

(right arrow) go to next episode
(left arrow) go to previous episode

On all image pages

a open add image window

On all edit pages

t open translation selector
ctrl+ s submit form

On discussion pages

n create new discussion
w toggle watching status
p toggle public/private
c toggle close/open
a open activity
r reply to discussion
l go to last reply
ctrl+ enter submit your message
(right arrow) next page
(left arrow) previous page

Settings

Want to rate or add this item to a list?

Login