Free tools Windows power users keep installed
One-click scans. No signup required.
To add a Microlink screenshot to a WordPress preview plugin, send the target page URL to Microlink with screenshot capture enabled, make the request through WordPress’s HTTP API, validate the response, and cache the result with a transient. Use Microlink’s JSON response when you need screenshot metadata; use its direct-image mode when you only need an image URL. Treat user-submitted URLs as untrusted and use wp_safe_remote_get().
Choose how the plugin will deliver the screenshot
Microlink’s screenshot API accepts a target url and a screenshot option. A normal API response includes a hosted screenshot asset URL and metadata. The other option is to request the screenshot field directly as an image response.
As an Amazon Associate I earn from qualifying purchases.
| Delivery | Use it when | Trade-off |
|---|---|---|
| JSON response | The plugin needs the screenshot URL plus metadata or may later display other response fields. | Your code must check and decode JSON, then extract the screenshot asset URL. |
Direct image using embed=screenshot.url |
The display only needs an image source. | You receive the selected image field rather than a structured response for application logic. |
Microlink documents both delivery modes in its API response documentation and embedding guide. This walkthrough uses JSON because it makes response validation and caching explicit.
Quick wins for a faster PC:
Clear out junk files and repair common Windows errorsFree Scan →Scan for outdated or missing drivers - takes under a minuteDriver Scan →Repair Windows errors before they cause bigger problemsFix Now →Build a server-side request with WordPress’s HTTP API
Keep the Microlink call on your WordPress server rather than exposing API request logic in browser JavaScript. The example below accepts a page URL, requests a viewport PNG, checks for WordPress transport errors and an HTTP success response, decodes the JSON, and returns the screenshot asset URL. Microlink’s basic request and screenshot parameter are documented in its API parameters; WordPress documents the request and response helpers in its HTTP API guide.
#1 Best Overall
<?php
function my_plugin_microlink_screenshot( $target_url ) {
$target_url = esc_url_raw( $target_url );
if ( ! $target_url || ! wp_http_validate_url( $target_url ) ) {
return new WP_Error( 'invalid_url', 'Enter a valid public URL.' );
}
$cache_key = 'my_plugin_shot_' . md5( $target_url . '|png|viewport' );
$cached = get_transient( $cache_key );
if ( false !== $cached ) {
return $cached;
}
$api_url = add_query_arg(
array(
'url' => $target_url,
'screenshot' => 'true',
),
'https://api.microlink.io/'
);
$response = wp_safe_remote_get(
$api_url,
array(
'timeout' => 20,
'redirection' => 3,
)
);
if ( is_wp_error( $response ) ) {
return $response;
}
$status = wp_remote_retrieve_response_code( $response );
if ( $status < 200 || $status >= 300 ) {
return new WP_Error( 'microlink_http_error', 'Microlink returned HTTP ' . $status . '.' );
}
$data = json_decode( wp_remote_retrieve_body( $response ), true );
if ( ! is_array( $data ) || empty( $data['data']['screenshot']['url'] ) ) {
return new WP_Error( 'microlink_missing_screenshot', 'The response did not contain a screenshot URL.' );
}
$image_url = esc_url_raw( $data['data']['screenshot']['url'] );
if ( ! $image_url ) {
return new WP_Error( 'microlink_invalid_image_url', 'Microlink returned an invalid screenshot URL.' );
}
set_transient( $cache_key, $image_url, 6 * HOUR_IN_SECONDS );
return $image_url;
}
// Example use:
$image_url = my_plugin_microlink_screenshot( 'https://example.com/' );
if ( ! is_wp_error( $image_url ) ) {
printf( '<img src="%s" alt="Website preview" loading="lazy">', esc_url( $image_url ) );
}
The six-hour transient lifetime is an example policy, not a Microlink requirement. Change it to match how quickly previews should reflect page updates. Make the cache key include every capture setting that changes the output, such as image type, quality, full-page mode, selected element, or viewport.
URL safety and query construction
add_query_arg() handles query-string encoding for the API request. Do not concatenate a user-provided URL into a request string manually. WordPress specifically recommends wp_safe_remote_get() for URLs controlled by users because it validates the destination and helps guard against server-side request forgery. See the function reference. Validation alone does not replace capability checks or rate controls if visitors can trigger remote captures.
Render output in the right context
Escape the screenshot URL when placing it in an HTML attribute, as in the example. Do not print API response text as HTML. If the plugin stores a URL, validate it before storage and escape it again at output; escaping should happen for the context where data is used.
Rank #2
Select screenshot scope and image format
Microlink’s documented screenshot options let a plugin tune the image to its preview layout. Keep defaults simple for a link card, then expose additional controls only if users need them.
| Option | Documented behavior | When it helps |
|---|---|---|
fullPage |
Captures the scrollable page; documented default is false. |
Use when a long page must be represented in one image. A viewport capture is usually more suitable for a compact preview card. |
type |
PNG or JPEG; documented default is PNG. | Choose the format that fits the preview and storage or transfer needs. |
quality |
JPEG compression quality from 0 to 100; documented default is 80. Applies only to JPEG. | Adjust JPEG size-versus-detail trade-offs; it has no effect on PNG. |
element |
Captures an element selected by CSS selector, waiting for it to be visible. | Use when the plugin needs a particular page component rather than the full viewport. |
These settings are described in Microlink’s screenshot options reference. For element-specific or full-page captures, include those settings in the API request using the documented request format and include them in the cache key. A full-page image can be longer and take more time or bandwidth to deliver; that is a design consideration, not a published performance guarantee.
Cache previews without hiding failures
WordPress Transients provide temporary caching with an expiration time. Cache successful screenshot URLs or response data so repeated requests for the same page and settings do not needlessly call the remote API. Pick the expiry based on the preview’s purpose: a frequently changing monitoring view needs shorter freshness windows than a static link card. WordPress explains transient behavior in its Transients API documentation.
- Build the cache key from the normalized target URL and all screenshot settings that affect the result.
- Cache successful results; do not cache a transport error or malformed response as if it were an image.
- Return a graceful placeholder or omit the preview when the API call fails, rather than breaking the surrounding page.
- Do not assume a particular Microlink CDN retention period. Its API overview lists configurable TTL among Pro features, but plan details can change; check the current API overview.
Protect public and authenticated preview routes
A preview generated only by an administrator has a different abuse profile from an endpoint any visitor can use. Decide who can submit target URLs before exposing the request function through a shortcode, block, or REST route.
PC Slower Than It Used to Be?
A free scan shows the junk files, broken settings and background clutter dragging Windows down - then fixes them in one click.Free scan · Windows 10 & 11Outdated Drivers Are Slowing You Down
One free scan finds every outdated or missing driver and matches the right update for your exact hardware.Free scan · exact hardware match- For editor-only generation, check the user’s capability before making a remote request.
- For an authenticated WordPress REST route, use the platform’s cookie and nonce protections described in the REST API authentication guide.
- For a public route, set request-rate limits and other abuse controls, and account for the fact that every call can consume your Microlink quota.
- Set a finite request timeout and limit redirects. The example uses a 20-second timeout and three redirects as implementation choices, not required vendor values.
Handle errors without breaking the preview page
Remote screenshot generation can fail independently of WordPress rendering. Treat the screenshot as optional UI: check each failure point, log enough for administrators to diagnose it, and keep visitor-facing output calm.
| Symptom | Likely cause | Handling |
|---|---|---|
WP_Error from the request |
Network, DNS, TLS, timeout, or safe-request validation failure. | Show a placeholder, avoid caching the error as a successful result, and record a useful server-side diagnostic. |
| Non-2xx HTTP response | Microlink rejected the request, the service returned an error, or a quota/plan condition applies. | Check the status and relevant response details before retrying; do not decode it as a successful screenshot payload. |
| Invalid or incomplete JSON | The body is empty, malformed, or not the expected API response. | Check json_last_error() if needed and handle missing data.screenshot.url as a failed preview. |
| Screenshot URL missing | The remote capture did not produce the expected screenshot field. | Do not render an empty src; fall back to the plugin’s no-preview state. |
| Slow preview generation | Remote page loading or screenshot capture is taking longer than the plugin’s synchronous request allows. | Use a suitable finite timeout, cache completed results, and consider generating previews asynchronously if the plugin architecture supports it. |
WordPress’s response helper functions and error handling are covered in the HTTP API guide. This workflow is an implementation pattern based on documented API interfaces, not a claim that a particular WordPress plugin has been tested.
Rank #4
Understand Microlink’s free allowance and plan limits
Microlink’s screenshot guide currently says the API works without an API key and provides 25 free requests per day. That figure is the vendor’s published allowance accessed in 2026, not a guaranteed permanent quota. The guide says production use may call for a plan; verify current terms in the screenshot API guide and the API overview before designing a public feature around a quota.
Or skip the browser setup
If you would rather call a screenshot API than maintain capture integration code, ScreenshotNeo accepts a URL in one GET request and returns an image or PDF. For example:
curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://example.com -o shot.webp
See the ScreenshotNeo API documentation for request options. It accepts cookie and consent banners before capture and removes more than 60 known consent platforms, newsletter popups, and chat widgets; each cleanup step can be turned off. Bot checks/CAPTCHAs, blank pages, timeouts, failed loads, and cache hits are not billed, and response headers identify the page verdict and billing status. Its MCP server provides take_screenshot, get_page_info, and capture_pdf for AI agents. The free plan includes 1,000 screenshots a month with no card; paid plans start at $5 for 3,000 shots.
Sign up free for 1,000 screenshots a month—no card required.
Best Value
Frequently Asked Questions
Can I display a Microlink screenshot without parsing JSON?
Yes. Microlink documents embed=screenshot.url as a direct-image delivery mode. Use it when the plugin only needs an image source; use JSON when you need response metadata.
Does WordPress cache transients indefinitely?
No. A transient is temporary data with an expiration you choose; the cache key and lifetime should reflect the URL and screenshot settings.
Quick Recap
Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.




