Stream from the CDN, not your repo

Day 2, 20 minutes · beginner

Goal of this lessonUse a hosted Pexels or Unsplash image in your app by URL only — never committing the file.

The trap you''re avoiding

The obvious way to add an image to your app is: download it, drop it in /public/, commit it. This is the wrong move for stock media.

  • Your git repo gets heavier every time — forever, because of git history
  • Vercel / Netlify / Cloudflare count every byte against your bandwidth quota
  • You lose the ability to swap the image without a code change and a deploy

Better pattern: reference the CDN URL directly. The stock vendor already serves the image from a fast CDN. Let them pay the bill.

How to get a CDN URL

From Unsplash: open an image page, right-click the image → "Copy image address." You get something like:

https://images.unsplash.com/photo-1554224155-8d04cb21cd6c?w=1200

From Pexels: on a photo page, right-click the hero image → "Copy image address." Same idea. For videos, grab the poster image URL the same way.

Both sites serve these URLs globally over CDN, forever, for free.

Use it in your app

HTML:

<img src="https://images.unsplash.com/photo-1554224155-8d04cb21cd6c?w=1200"
     alt="..."
     loading="lazy" />

React / Astro / Next / Vue — identical. The URL is just a URL.

The one rule that will bite you

If the URL you copied already has ? query params (it usually does on Pexels and Unsplash — they use them for server-side resizing), don''t naively append more with another ?. Use & for the second parameter:

// ❌ Breaks: two question marks
`${image}?w=1200&q=80`

// ✅ Safe
`${image}${image.includes(''?'') ? ''&'' : ''?''}w=1200&q=80`

This bug shipped to production in the project that inspired this course. Catches everyone once.

Today's actions

Ticks are not saved without an account

Do it in your tool

Claude

  1. In your browser, open the image page on Unsplash or Pexels, right-click the image and choose Copy image address, as the lesson shows. This step happens outside Claude.
  2. Install or open the Claude desktop app, sign in and click the Code tab at the top of the sidebar.
  3. In the row under the prompt box, click the environment selector and select the top entry in the Local group. Then click the project folder control, select Open folder… and choose your project.
  4. In the mode selector in the same row, pick Manual, so Claude asks before it edits a file or runs a command.
  5. Paste this prompt, put your file name and your copied address in it and press Enter.
    In [YOUR FILE], add this image as an img tag whose src is this address: [PASTE THE IMAGE ADDRESS]. Do not download the image and do not add any image file to the project. Keep the existing classes, add loading="lazy" and write useful alt text. If the address already contains a ?, join any extra parameter with & and never with a second ?. Then tell me which files changed and confirm that no image file was added.
  6. Read the diff (the list of changed lines) before you approve it. It must hold a text address in your code, not a new image file in your project.
  7. Click the line-count indicator (such as +12 -1) in the Changes card of the session details panel to open the diff view. Check that only text lines changed.
  8. Ask Claude what files have I changed? and then commit my changes with a descriptive message. No image or video file in the list means you are done.

Note: In Claude this task runs in Claude Code, the Code tab of the desktop app (macOS and Windows; Linux is a beta). In Manual mode Claude also asks before it runs a command such as the commit. On a Team or Enterprise plan an admin can switch off Claude Code in the desktop app. The Claude Code tab of this lesson shows the same task in the terminal. No paid Claude plan? The ChatGPT and Gemini tabs of this lesson need none.

Paid planNeeds a paid Claude plan: Pro, Max, Ultra, Team or Enterprise. The Free plan does not include Claude Code.

Checked on 30 November 2026 · Source: Claude Code docs: Get started with the desktop app (opens in a new tab)

Unsplash for Developers ↗ (opens in a new tab)

Create a free account to save your progress. Sign in or sign up