Website screenshots in WordPress
Generate and display website thumbnails on your WordPress site
Integrate the Allscreenshots API with your WordPress site to automatically generate and display website screenshots. Perfect for link directories, resource pages, portfolio galleries, and affiliate sites that need visual previews of external URLs.
Get your API key
Sign up for Allscreenshots and grab your API key from the dashboard.
Add a custom function
Add a PHP function to your theme or a custom plugin to call the Allscreenshots API.
Display screenshots
Use a shortcode or block to display website screenshots in posts and pages.
Cache results
Use WordPress transients to cache screenshot URLs and avoid redundant API calls.
1<?php
2// Add to functions.php or a custom plugin
3function allscreenshots_shortcode($atts) {
4 $atts = shortcode_atts([
5 'url' => '',
6 'width' => 1280,
7 'height' => 800,
8 'fullpage' => 'false',
9 ], $atts);
10
11 if (empty($atts['url'])) return '';
12
13 $cache_key = 'screenshot_' . md5($atts['url']);
14 $screenshot_url = get_transient($cache_key);
15
16 if (!$screenshot_url) {
17 $response = wp_remote_post(
18 'https://api.allscreenshots.com/v1/screenshot',
19 [
20 'headers' => [
21 'Authorization' => 'Bearer ' . SCREENSHOT_API_KEY,
22 'Content-Type' => 'application/json',
23 ],
24 'body' => wp_json_encode([
25 'url' => $atts['url'],
26 'fullPage' => $atts['fullpage'] === 'true',
27 'viewport' => [
28 'width' => (int) $atts['width'],
29 'height' => (int) $atts['height'],
30 ],
31 ]),
32 ]
33 );
34
35 $body = json_decode(wp_remote_retrieve_body($response));
36 $screenshot_url = $body->screenshotUrl;
37 set_transient($cache_key, $screenshot_url, DAY_IN_SECONDS);
38 }
39
40 return sprintf(
41 '<img src="%s" alt="Screenshot of %s" loading="lazy" />',
42 esc_url($screenshot_url),
43 esc_attr($atts['url'])
44 );
45}
46add_shortcode('screenshot', 'allscreenshots_shortcode');
47// Usage: [screenshot url="https://example.com"]Simple shortcode
Display screenshots anywhere with [screenshot url="..."]. No coding beyond the initial setup.
Built-in caching
WordPress transients cache screenshot URLs to minimize API calls and speed up page loads.
No plugin dependency
A lightweight function — no bloated plugin needed. Add it to your theme or a mu-plugin.
Read the full tutorial
Step-by-step guide to integrating Allscreenshots with WordPress, including advanced options and best practices.
Read the blog postPricing that scales with you
No hidden fees. No surprises. Just screenshots.
100 free screenshots on sign-up · 50 bonus for each friend you invite
Pro
- 7,500 screenshots/mo
- 100/min rate limit
- $0.009 overage
- All features included
Business
- 30,000 screenshots/mo
- 200/min rate limit
- $0.0075 overage
- All features included
Enterprise
- 100,000 screenshots/mo
- 400/min rate limit
- $0.005 overage
- All features included