Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Specific height and width of a photo in an API request

One of the features of the taxi renting service application that I'm writing is to add a taxi with random properties, including a photo. When I make a get request to the Unsplash API service, I should be receiving a photo with specific measures, based on their documentation: https://unsplash.com/documentation#get-a-random-photo

The call I make is:

$http.get('https://api.unsplash.com/photos/random?client_id=7b8105b594859445adc64d0dfe73fc9282dda72dfc283476dd166899a441df10&query=taxi&h=500&w=300');

Notice the '&h=500&w=300'. This, however, always produces a photo of random measurements, even though I followed their documentation. I am relatively new to programming and even though I searched for a solution, I did not find it, so I would very much appreciate your help.

like image 755
Vid Avatar asked Oct 21 '25 21:10

Vid


1 Answers

Note: Supplying the optional w or h parameters will result in the custom photo URL being added to the urls object:

{
  "urls": {
    "raw":     "...",
    "full":    "...",
    "regular": "...", 
    "small":   "...",
    "thumb":   "...",
    "custom":  "https://images.unsplash.com/your-custom-image.jpg"
  }
}
like image 78
Sergey Avatar answered Oct 23 '25 13:10

Sergey