Skip to content

How to Build a Thumbnail Fetcher for Links You Are Licensed to Use

A step-by-step guide to a thumbnail fetcher that only touches links you are licensed to use, with validation, resizing, caching and safe handling of failures.

9 min readUpdated Nov 15, 2026By XPASS Editorial Team

How to Build a Thumbnail Fetcher for Links You Are Licensed to Use

A thumbnail is the small picture that makes a list of videos, articles or products easy to scan. It is also one of the most frequently requested resources in any media-driven product, so it deserves a proper component rather than an ad hoc image tag. A thumbnail fetcher is that component: it takes an address, downloads the image, checks it, prepares it for display and keeps it ready for the next visitor.

This guide shows how to build one for links you are licensed to use. That phrase matters. The fetcher should only touch images that a source offers through an official interface, that you own, or that an agreement covers. The sections below cover permission checks, a safe fetch routine, image processing, caching, failure handling and the limits to keep in mind. The fetcher is one part of a larger system, so it helps to read how to design a system that reads public media data through an API alongside this article.

Start with permission, not with code

Before you download a single image, decide what you are entitled to do. Write down, for each source, whether the terms let you store a copy, whether you must display the image from the source's own address, whether you may resize or crop, and what attribution is required. These answers change the whole design. If a source requires hot-linking, your fetcher may only need to verify that a link works and record its size. If copying is allowed, you can store a resized version and serve it from your own storage.

A reliable way to keep this under control is a small permission record for each source, stored in configuration. It might hold the allowed host names, whether storage is permitted, the maximum age of a stored copy and the attribution text. The fetcher reads this record before every job, and refuses to continue if the source is not listed. This single rule prevents most accidents, such as a typo in a URL leading to a request to an unrelated site.

Also check the site's automated-access guidance. If a thumbnail comes from a public web page rather than an official interface, read its terms and its robots.txt file as described in RFC 9309. If the answer is unclear, ask the owner. Do not build a workaround for restrictions, rate limits or access controls.

Where the thumbnail address comes from

In a well-designed system the fetcher does not guess addresses. It receives them from a metadata step. The metadata response for a media item typically contains one or more thumbnail URLs, often in several sizes. Your normalizer picks the best candidate and stores it as thumbnailUrl, with the source's item identifier next to it. The fetcher then works from a queue of jobs that contain only the identifier and that address. To see why reading descriptive data first usually beats downloading files, see how a media metadata API differs from file download.

Prefer the smallest size that suits your layout. If your cards are 320 pixels wide, requesting a 1,280-pixel original wastes bandwidth and storage. When a source offers several variants, choose one slightly larger than the biggest size you display, so that high-density screens still look sharp.

A safe fetch routine, step by step

Fetching an image from a remote address is a classic place for security mistakes, because your server makes a request to an address that came from outside. A careful routine looks like this.

  1. Check the host. Compare the URL's host with the allowed list from the permission record. Reject anything else, including addresses that point to private or internal network ranges.
  2. Send a clear request. Use a plain GET with an honest user-agent string that identifies your application, and a short timeout. Ask only for image content types.
  3. Handle redirects deliberately. Follow a small number of redirects, and re-check the host after each one. A redirect to an unexpected host is a reason to stop.
  4. Read the status. Interpret the response according to HTTP Semantics (RFC 9110): success, not modified, not found, forbidden and so on each call for a different action.
  5. Limit the size. Stop reading if the body exceeds a maximum number of bytes, even if the headers claim something smaller.
  6. Check the type. Verify the declared content type and, ideally, the real file signature. Accept only the image formats you support.
  7. Process in isolation. Decode and resize in a separate step, preferably with limits on memory and dimensions, so that a malformed file cannot exhaust your server.

A plain example helps. Suppose your catalogue shows courses that a training partner has licensed to you. The partner's API returns a thumbnail address on its own image host. Your permission record lists that host, allows storage and sets a maximum copy age. The fetcher receives a job, confirms the host, downloads at most a few megabytes within a few seconds, checks that the file really is a JPEG or PNG, and passes it to the resizer.

Resizing, formats and storage

Once the file is validated, prepare it for display. Most products need two or three sizes: a small one for lists, a medium one for cards and sometimes a larger one for detail pages. Generate them once at fetch time instead of resizing on every request. Keep the aspect ratio, decide on a fixed crop only if your design requires it, and strip metadata you do not need, since embedded data can include details that should not be published.

Decision Options Practical advice
Sizes Small, medium, large Create only the sizes your layout uses
Format Original, JPEG, PNG, modern formats Serve a modern format where browsers support it, keep a fallback
Storage Own storage, object store, none Store only if the terms allow it
Naming By item identifier and size Avoid using the source's file name
Metadata Keep or strip Strip unneeded embedded data

Record with each stored image the source item identifier, the original address, the fetch time, the checksum and the size variant. When something looks wrong later, this information lets you find out where an image came from and decide quickly whether to refetch or remove it.

Caching and conditional requests

A fetcher that downloads the same image again and again is wasteful and impolite. Use the validators that HTTP provides. When a response includes an entity tag or a last-modified time, store it. On the next refresh, send a conditional request. If the image has not changed, the source answers that it is unchanged and no body is transferred. This saves bandwidth for both sides.

Add a refresh policy on top. A reasonable one is to refresh thumbnails lazily: when an item is shown and its copy is older than your chosen age, serve the current copy and queue a refresh. Respect the source's own cache hints as an upper limit. Avoid refreshing everything on a fixed schedule, because most thumbnails never change, and a daily full refresh creates traffic for no benefit.

For delivery to your users, put the stored images behind your own content delivery layer with long cache lifetimes, and use versioned file names so that a changed image gets a new address. That way your visitors rarely wait on the fetcher at all.

Where a proxy may help, and the limits

A proxy is an intermediary that sends requests for you, as the MDN guide to proxy servers and tunneling explains. For a thumbnail fetcher its use is modest. You might send your fetch jobs from a stable network location, so that a licensed partner can recognise your traffic, or you might test how a source serves images to visitors in another region for the sake of your own regional pages. If you want to look at such options, the XPASS proxy page explains what is available and what each plan includes.

A proxy does not give you rights. It must not be used to disguise heavy request volumes, get around a source's limits, or reach content you are not licensed to use. Keep the setting per source, in configuration, so it is visible to anyone who reviews the system.

Failures, expiry and fallbacks

Thumbnail links break often. Some are signed and expire after minutes or hours, some are removed when the owner updates the item, and some simply stop working. Plan for this from the beginning.

  • Not found or gone. Keep the last good copy if the terms allow it, mark the item for a metadata refresh to obtain a new address, and do not retry the old one forever.
  • Forbidden or unauthorized. This can mean an expired signature or a credential problem. Trigger a metadata refresh once; if it fails again, alert the owner of the integration.
  • Timeouts and server errors. Retry a few times with backoff, then try again later from the queue.
  • Invalid file. Reject it, log the reason and keep the earlier copy.
  • Nothing available. Show a neutral placeholder so that the layout does not break.

The next article in this series, on handling expired media links in your system, goes deeper on the refresh pattern. For now, the key point is that the fetcher should report an expired link as a normal, expected result and not as a crash.

Limits and what to watch for

  • Rights can differ per image. A source may license text and thumbnails differently. Check each field's terms, not only the source as a whole.
  • People and sensitive content. Thumbnails can show faces or private details. Apply the privacy rules that govern you, and be ready to remove an image promptly if its owner asks.
  • Attribution. If the terms require credit, store the credit text with the image and display it wherever the image appears.
  • Storage growth. Many sizes of many items add up. Set a clean-up rule that removes copies for items you no longer show.
  • Accessibility. Provide alternative text for thumbnails that carry meaning, and do not rely on the picture alone.
  • Security. Treat every remote file as untrusted. Keep the allow list tight, limit sizes and keep image libraries updated.

Testing the fetcher

Before you rely on the fetcher, test it against a small local server that you control. Give it cases for success, a redirect to an allowed host, a redirect to a disallowed host, an oversized file, a text file named like an image, a slow response and an expired link. Check that each case ends in the behaviour you wrote down. Add these tests to your automated suite, so that a later change to the fetch routine cannot quietly remove a safety check. Finally, review the permission records on a schedule, because the most common failure of a thumbnail fetcher is not a technical bug but a change in the terms nobody noticed.

Summary

A thumbnail fetcher is safest and most useful when it works only on links you are licensed to use, receives its addresses from a metadata step, and validates host, size and type before processing anything. Resize once, store with enough information to trace each image, and use conditional requests and lazy refresh to avoid needless traffic. Treat expired links as expected events with clear fallbacks, respect attribution and privacy rules, and use a proxy, if at all, only as a visible routing setting. When you want to see which network options suit lawful testing and routing, the proxy page is a good place to start.

Frequently asked questions

What is a thumbnail fetcher?

It is a component that takes a thumbnail address you are allowed to use, downloads the small image, checks it, resizes it if needed and stores or serves it inside your own product so that pages load quickly.

Do I need permission before fetching thumbnails?

Yes. Only fetch thumbnails from sources that offer them through an official interface, from content you own, or under a licence or agreement that covers the use. Having a link that opens in a browser is not the same as having the right to copy the image.

Should I store thumbnails or hot-link them from the source?

It depends on the terms. Some sources require you to display images from their own address, while others allow you to keep a copy. Read the terms first, and if storing is allowed, keep the original address and the fetch time next to the copy.

How do I keep the fetcher safe?

Allow only known hosts, accept only image content types, limit the size and time of each download, never follow redirects blindly, and process images in an isolated step. These checks stop a bad link from harming your servers.

What happens when a thumbnail link expires?

The fetcher receives an error such as not found or forbidden. It should keep the last good copy if the terms allow, mark the item for a metadata refresh to get a new link, and show a placeholder if nothing is available.

About the author

Bob Kanokphon Thongdee, founder of XPASS VPN

Bob Kanokphon Thongdee

  • Founder of XPASS VPN
  • Co-founder of eSIMonline.asia
  • More than 7 years in online marketing
  • Founder of Cojourney Visa and Cojourney Travel

Need a proxy for this?

XPASS Proxy sells residential proxy traffic by the gigabyte, with the price shown before you pay.

See proxy plans

Keep reading

Proxy Guides

How to Design a System That Reads Public Media Data Through an API

A practical blueprint for reading public media data through an API: define scope, split the system into layers, cache sensibly and respect each source's terms.

9 min read

Proxy Guides

How to Handle Expired Media Links in Your System

Media links often stop working after a while. Learn how to store stable identifiers, detect expiry, refresh links on demand and fail gracefully.

9 min read

Proxy Guides

How a Media Metadata API Differs From Downloading the File

Reading information about a media item and copying the media itself are different actions. This guide compares them across size, permission, risk and design.

9 min read