Day 2, 20 minutes · beginner
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 accountDo it in your tool
Claude
- 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.
- Install or open the Claude desktop app, sign in and click the Code tab at the top of the sidebar.
- 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.
- In the mode selector in the same row, pick Manual, so Claude asks before it edits a file or runs a command.
- 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. - 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.
- 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. - Ask Claude
what files have I changed?and thencommit 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.
ChatGPT
- 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 ChatGPT.
- Install or open the ChatGPT desktop app (macOS or Windows) and sign in with your ChatGPT account.
- Select Codex from the ChatGPT dropdown. Codex is a separate view with its own history.
- Open your project folder: on Windows click Add new project or press Ctrl+O, on macOS press Cmd+O.
- Paste this prompt in the composer, put your file name and your copied address in it and send it. Do not attach or download the image file.
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. - Open the review tab (Ctrl+Shift+G on Windows) and check the diff (the list of changed lines): text lines only, zero image bytes. On macOS, check with your own Git tool, for example
git status: it lists the changed and new files. - Click Stage all in the review pane. Then commit from the review pane or with your own Git tool.
- No Codex yet? In Chat on the web, use the prompt from the Gemini tab of this lesson, copy the code from the code block in the answer and put it into your file yourself.
Note: No paid plan needed: Codex is included on every plan. On Free and Go the Codex allowance is limited, and Codex in the desktop app is subject to rollout. The review tab needs a project inside a Git repository. Chat on the web cannot change files on your computer, so in that route you paste and commit the code yourself. A workspace admin can switch Codex off.
Gemini
- 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 Gemini.
- On a computer, go to
gemini.google.com. Below the text box at the bottom, click Add Files, then Canvas. - Paste this prompt in the text box, put your copied address and your alt text in it and click Submit.
Write an HTML img tag that uses this image address as its src: [PASTE THE IMAGE ADDRESS]. Add loading="lazy" and this alt text: [YOUR ALT TEXT]. If the address already contains a ?, join any extra parameter with & and never with a second ?. Do not download or embed the image. - Click Code at the top right of the Canvas panel to read the snippet. Check that your address is the src and that nothing is downloaded.
- Copy the snippet by hand from the Code view into your own project file.
- Commit the change with your own Git tool and look at the diff (the list of changed lines): no image file, zero image bytes added.
Note: No paid plan needed: Canvas works without a Google AI plan. Canvas writes the snippet but cannot change files in your project, so you paste and commit it yourself. Do not assume the Canvas preview shows images from Unsplash or Pexels: a blank preview is a limit of the preview, not of your code. Do not share the Canvas: shared Canvas links are public.
Microsoft Copilot
- 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 Copilot.
- Go to
copilot.cloud.microsoftand sign in with your work or school account. - Paste this prompt in the Message Copilot box, put your copied address and your alt text in it and select Send.
Write an HTML img tag that uses this image address as its src: [PASTE THE IMAGE ADDRESS]. Add loading="lazy" and this alt text: [YOUR ALT TEXT]. If the address already contains a ?, join any extra parameter with & and never with a second ?. Do not download or embed the image. - Read the snippet. Check that your address appears once, that an extra parameter is joined with & when a ? is already there, and that nothing is downloaded.
- Copy the snippet by hand into your own project file.
- Commit the change with your own Git tool and look at the diff (the list of changed lines): no image file, zero image bytes added.
Note: No extra Copilot plan needed: Copilot Chat (Basic) is included with eligible Microsoft 365 licences for work or school accounts. Microsoft Copilot Chat writes the snippet, and you paste and commit it yourself. Copilot Code, the Code tab of the Microsoft Copilot desktop app, can edit a project folder. It is a paid preview: personal accounts get it only in the United States and Canada, and work accounts in the Netherlands are not confirmed. So this lesson does not use it.
Claude Code
- 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 Code.
- Install Claude Code: in Windows PowerShell run
irm https://claude.ai/install.ps1 | iex, on macOS, Linux or WSL runcurl -fsSL https://claude.ai/install.sh | bash. - Open a new terminal and run
claude --versionto check that it is installed. - Go to your project folder in the terminal and run
claude. Log in when it asks you to. - Paste this prompt with your file name and your copied address in it.
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. - Read the change Claude Code makes. If it asks first, select Yes.
- Ask
what files have I changed?and check that only code files appear, with no image or video file. - Ask
commit my changes with a descriptive message, then ask which files the commit contains. Zero image files means you are done.
Note: This is the terminal route. If you prefer a window, the Claude tab of this lesson shows the same task in the Code tab of the Claude desktop app. From version 2.1.283 Claude Code starts in auto mode in the terminal. The status bar shows the current mode: check it before you start. Read every change yourself.
Paid planNeeds a paid Claude plan (Pro, Max, Ultra, Team or Enterprise) or a Claude Console account. The Free plan does not include Claude Code.
Create a free account to save your progress
Free, and no payment details. Your ticks and finished lessons are kept, on every device.
Create a free account I already have an accountCreate a free account to save your progress. Sign in or sign up