---
title: "Photos — Google Places for Laravel | Roundly"
description: "Build photo media URLs, or fetch photo bytes server-side, save them to any disk and get a key-free URL for the browser."
url: https://roundly-consulting.com/open-source/docs/google-places-for-laravel/photos
language: en
---

[All packages](https://roundly-consulting.com/open-source.md)

[Google Places for Laravel](https://roundly-consulting.com/open-source/docs/google-places-for-laravel.md)

# Photos

Places carry photo resource names in $place->photos. photoUrl() builds the media URL for one of them:

```php
use RoundlyConsulting\GooglePlaces\Facades\GooglePlaces;

// $photoName is a photo resource name from a place ($place->photos).
$url = GooglePlaces::photoUrl($photoName, maxWidth: 800, maxHeight: 600);
```

photoUrl() embeds your API key as the key query parameter, so keep that URL server-side. For anything that reaches a browser, use photo().

## Fetching photo bytes

photo() returns a handle on one place photo. The API key is sent as a request header and never exposed to the browser — url() returns Google’s key-free media URL:

```php
use RoundlyConsulting\GooglePlaces\Facades\GooglePlaces;

// $photoName is a photo resource name from a place ($place->photos).
$photo = GooglePlaces::photo($photoName, maxWidth: 800, maxHeight: 600);

$url   = $photo->url();                   // Google's key-free media URL (safe for the browser)
$bytes = $photo->contents();              // raw image bytes
$path  = $photo->save('public', 'p.jpg'); // store on a filesystem disk → returns the path

// The same two requests without the handle:
GooglePlaces::photoUri($photoName, 800, 600);
GooglePlaces::photoContents($photoName, 800, 600);
```

- url() — runs photoUri(): Google’s final media URL without your key, safe to put in an <img> tag.
- contents() — runs photoContents(): the raw image bytes.
- save($disk, $path) — writes the bytes to any Laravel filesystem disk and returns the path.
- Width and height default to 1600 px; a failed fetch or a missing key throws a PlacesException.

Every photo request goes through the client like any other call: configured timeouts and connection retries, paced on the places rate-limit budget, reported through the lifecycle events and intercepted by GooglePlaces::fake(). Photos are never cached — store the ones you reuse:

```php
// Cache a place's hero image locally once:
$path = "places/{$place->id}.jpg";

if (! Storage::disk('public')->exists($path) && $place->photos !== []) {
    GooglePlaces::photo($place->photos[0], 1200, 800)->save('public', $path);
}
```

## Show your open-source love

This package is free and MIT-licensed. If it saves you time, a one-off donation or a Patreon membership keeps it maintained, tested and documented.

[More ways to support, including crypto](https://roundly-consulting.com/support-us.md)

By donating, you agree to our [donation terms](https://roundly-consulting.com/donation-terms.md).

[Support our open source work (opens in a new tab)](https://donate.stripe.com/dRmeVe8FX5PF1Qd9pXcEw00) [Join us on Patreon (opens in a new tab)](https://www.patreon.com/cw/roundly)

## Want this built into your product?

We integrate our packages into custom Laravel and AI builds. Tell us what you're working on and we'll reply within 48 hours.

[Get a quote in 48 hours](https://roundly-consulting.com/contact.md) [Browse all packages](https://roundly-consulting.com/open-source/docs/google-places-for-laravel.md)
