What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

To add Microlink screenshots to a WordPress website preview plugin, request a screenshot for a validated target URL with WordPress’s HTTP API, check the response, cache the result in a transient, and render the returned image URL. Use Microlink’s JSON response when the plugin needs image metadata; choose its direct-image embed mode when the page only needs an image source.

Choose how the preview should be delivered

Microlink’s screenshot API takes the page URL and a screenshot parameter. In its normal JSON workflow, the response contains a hosted screenshot asset URL and metadata. That gives a plugin room to inspect the result before displaying it. If the plugin only needs an image source, Microlink also documents a direct-image mode using embed=screenshot.url.

Delivery Use it when What the plugin receives
JSON response You need screenshot metadata, need to validate the returned data, or may use additional response fields. Structured response data including the hosted screenshot URL.
Direct image embed You need only an image source for markup. The selected screenshot field as an image response with an appropriate content type.

For a link card, a viewport screenshot is usually a more compact preview than a full-page image. That is a design choice, not a measured performance guarantee. Microlink’s direct-image mode is documented at https://microlink.io/docs/api/parameters/embed.

Build a server-side WordPress request

Use WordPress’s HTTP API rather than introducing a separate HTTP client for an ordinary server-side GET request. The example below accepts a target URL, uses wp_safe_remote_get() because the URL may be user-controlled, checks transport and HTTP errors, decodes JSON, and verifies that a screenshot URL is present before returning it.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
#1 Best Overall
Elebase USB to USB C Adapter for iPhone 18 Pro Max,USBC Car Charger Adapter
  • Read Before You Buy — No Video Output: These adapters support charging and USB 2.0 data transfer, but cannot transmit video signals. Except for standard USB webcams (which use USB data only), they are not compatible with HDMI/DisplayPort cables, video-capable USB-C hubs, or docking stations with video output.
  • Convert USB-A Ports to USB-C: Designed to connect USB-C earphones, cables, flash drives, card readers, and other USB-C accessories to standard USB-A ports. Plug-and-play with no drivers or software required.
  • Aluminum Alloy Housing: Built with a sturdy aluminum alloy shell that aids in heat dissipation and protects against daily wear and scratches. Designed to maintain a stable and secure connection.
  • Compact & Travel-Friendly: The ultra-compact design allows the adapter to stay plugged into your device without blocking adjacent ports or adding bulk, reducing wear and tear on your original USB ports.
  • 12-Month Warranty: Backed by a 12-month manufacturer warranty for peace of mind. Designed to meet strict quality control standards for reliable everyday performance.
<?php
function my_preview_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_preview_url', 'Enter a valid website URL.' );
    }

    $cache_key = 'my_preview_' . md5( $target_url );
    $cached    = get_transient( $cache_key );

    if ( false !== $cached ) {
        return $cached;
    }

    $endpoint = add_query_arg(
        array(
            'url'        => $target_url,
            'screenshot' => 'true',
        ),
        'https://api.microlink.io/'
    );

    $response = wp_safe_remote_get(
        $endpoint,
        array(
            'timeout'     => 20,
            'redirection' => 3,
            'headers'     => array( 'Accept' => 'application/json' ),
        )
    );

    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', 'The screenshot service returned an unsuccessful response.' );
    }

    $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', 'No screenshot was returned for this page.' );
    }

    $result = array(
        'url'    => esc_url_raw( $data['data']['screenshot']['url'] ),
        'width'  => isset( $data['data']['screenshot']['width'] ) ? absint( $data['data']['screenshot']['width'] ) : 0,
        'height' => isset( $data['data']['screenshot']['height'] ) ? absint( $data['data']['screenshot']['height'] ) : 0,
    );

    if ( ! $result['url'] ) {
        return new WP_Error( 'microlink_invalid_image_url', 'The screenshot response did not contain a usable image URL.' );
    }

    set_transient( $cache_key, $result, HOUR_IN_SECONDS );
    return $result;
}

function my_preview_render_screenshot( $target_url ) {
    $shot = my_preview_microlink_screenshot( $target_url );
    if ( is_wp_error( $shot ) ) {
        return '<p>Preview image is unavailable.</p>';
    }

    return sprintf(
        '<img src="%1$s" alt="Website preview" loading="eager" />',
        esc_url( $shot['url'] )
    );
}
?>

Microlink’s screenshot parameter and response structure are described in its screenshot API documentation. WordPress documents request and response helpers in its HTTP API reference. The sample uses a one-hour transient expiration as an implementation default; choose a period that matches how quickly the pages shown in your preview should reflect changes.

Adapt request options deliberately

  • Full page: Set fullPage to capture the entire scrollable page instead of only the visible viewport. The documented default is false.
  • Image format: Choose type as PNG or JPEG; the documented default is PNG.
  • JPEG quality: Use quality from 0 to 100 for JPEG output only. The documented default is 80.
  • One element: Set element to a CSS selector to capture a matching DOM element; Microlink documents waiting for that element to become visible.

These screenshot options are documented in Microlink’s SDK screenshot parameter reference. Add only controls your plugin’s users need: full-page images can be much taller than card previews, while an element selector is useful when the desired image is a specific page component.

Rank #2
Anker USB-C Hub, 5-in-1 USB Hub for Laptops, 4K HDMI Multiport Adapter
  • 5-in-1 USB-C Hub: Experience comprehensive connectivity featuring a Power Delivery input, two USB-A 2.0 ports, a USB-A 3.0 port, and an HDMI port. (Note: The USB-C power delivery input port is only for connecting an external wall charger to power your laptop and cannot power peripheral devices.)
  • 90W Pass-Through Charging: Achieve optimal charging with 90W pass-through power to your laptop, supported by a total input of 100W, with the hub reserving 10W for operational efficiency. (Note: Wall charger not included.)
  • Quick Data Transfers: Accelerate your productivity with rapid data transfers using a high-speed 5Gbps USB 3.0 port and two 480Mbps USB 2.0 ports.
  • 4K HDMI Display: Enhance your visual experience with a hub capable of delivering 4K resolution at 30Hz in both mirror and extend modes. Please note that this hub is compatible with MacBook (macOS 12 and newer), Windows 10 and 11, ChromeOS, and laptops equipped with DP Alt Mode and Power Delivery. Note: This device is not compatible with Linux.
  • What You Get: Anker USB-C Hub (5-in-1, 4K HDMI), welcome guide, 18-month warranty, and our friendly customer service.

Validate inputs and protect public preview generation

Any URL entered by a user is untrusted. WordPress explicitly recommends wp_safe_remote_get() when making requests to user-controlled URLs; it validates the requested URL and helps guard against unsafe destinations. See the WordPress function reference.

  • Decide whether screenshot generation is available only to editors or administrators, or to public visitors as well. Check capabilities on privileged actions.
  • Validate and normalize submitted URLs before building the API request. Do not accept arbitrary request destinations without safeguards.
  • Set reasonable request timeouts and redirect limits. A remote capture can take longer than a local lookup, but an unbounded wait can tie up PHP workers.
  • For public preview routes, set rate limits and abuse controls so visitors cannot consume the plugin’s API allowance without limit.
  • For authenticated WordPress REST routes, follow WordPress nonce and cookie guidance to protect authenticated requests from cross-site request forgery. Public routes need their own authorization and abuse policy.

WordPress’s REST API guidance for cookie authentication and nonces is at https://developer.wordpress.org/rest-api/using-the-rest-api/authentication/.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #3
Sale
Anker USB C Hub, 7in1 Multi-Port USB Adapter, 4K@60Hz USBC to HDMI Splitter
  • Sleek 7-in-1 USB-C Hub: Features an HDMI port, two USB-A 3.0 ports, and a USB-C data port, each providing 5Gbps transfer speeds. It also includes a USB-C PD input port for charging up to 100W and dual SD and TF card slots, all in a compact design.
  • Flawless 4K@60Hz Video with HDMI: Delivers exceptional clarity and smoothness with its 4K@60Hz HDMI port, making it ideal for high-definition presentations and entertainment. (Note: Only the HDMI port supports video projection; the USB-C port is for data transfer only.)
  • Double Up on Efficiency: The two USB-A 3.0 ports and a USB-C port support a fast 5Gbps data rate, significantly boosting your transfer speeds and improving productivity.
  • Fast and Reliable 85W Charging: Offers high-capacity, speedy charging for laptops up to 85W, so you spend less time tethered to an outlet and more time being productive.
  • What You Get: Anker USB-C Hub (7-in-1), welcome guide, 18-month warranty, and our friendly customer service.

Cache by URL and capture settings

WordPress Transients store temporary values with an expiration and are suitable for caching a screenshot URL or response data. A cache key should include every input that changes the captured result—not just the page URL. For example, include full-page mode, format, quality, element selector, and any relevant viewport or display settings when those options are exposed.

Pick the expiration by the preview’s freshness needs. A mostly static directory listing may tolerate longer reuse; a frequently changing page may need a shorter lifetime. Caching reduces repeat API requests for the same input, but it also means a changed source page may not appear until the cached entry expires or is cleared. WordPress explains transient behavior in its Transients API documentation. Microlink also lists configurable cache TTL among Pro features in its API overview; do not assume a particular retention period beyond the terms shown for your account.

Rank #4
Sale
UGREEN USB to USB C Adapter Combo 4-Pack, 10Gbps USB C Converter Space Gray
  • Dual Converters, Infinite Potential:Includes 2× USB C male to USB A female adapters and 2× USB A male to USB C female adapters. Perfect for a wide range of uses—tablets with Bluetooth keyboards, expand USB ports on macbook, and more. Two different converters for all your daily needs
  • Next-Level 10Gbps & 3A Charging: No more slow 480Mbps, this usb to usb c adapter has a transfer speed of up to 10Gbps, allowing you to do more transferring in less time. This usb adapter fits both USB A and USB C charger, supporting up to 3A fast charging
  • Upgraded Exquisite Craftsmanship: With an aluminum alloy housing and metal connector, the usbc to usb adapter is extremely durable and sturdy. Rigorously tested to withstand more than 10,000 times of plugging and unplugging, ensuring long-lasting performance
  • Broad Compatible: The usb c to usb adapter widely supports all USB C/ USB A devices like laptops, tablets, cellphones, car chargers, and phone chargers. Such as compatible with MacBook Pro/Air 2023/2022, Thunderbolt 4/3 Devices,Apple MagSafe Watch 9/8/7/SE/Ultra, iPad Pro 2022/2021, Samsung Galaxy S23/S20/S10, and iPhone 17/16/15 Pro. Plug and play
  • Please Note: To reach 10Gbps speed, keep the cable under 3.3 ft. For USB A Male to USB C adapters, try flipping the USB C connector. USB C Male to USB A adapters support bidirectional 10Gbps transfer within 3.3 ft

Use direct-image mode for markup-only previews

If no JSON fields are needed, request the screenshot field directly by adding embed=screenshot.url to the Microlink request. The response is then the selected image field with an image content type, which can simplify the image-source workflow. Treat the response as an image rather than decoding it as JSON; check the request result and handle failures before emitting a source URL. The mode is documented at Microlink’s embed parameter reference.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Or skip the browser setup

For a screenshot endpoint without configuring your own browser workflow, ScreenshotNeo is a website screenshot API and MCP server. A single GET request can return an image or PDF; its capture can accept cookie banners and remove more than 60 known consent platforms, newsletter popups, and chat widgets, with each step independently switchable. Bot checks, blank pages, failed loads, timeouts, 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 tools for AI agents.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

One-call cURL example, using the documented endpoint and parameters (see the ScreenshotNeo API docs):

Best Value
Anker USB C Hub, 5-in-1 USBC to HDMI Splitter with 4K Display
  • 5-in-1 Connectivity: Equipped with a 4K HDMI port, a 5 Gbps USB-C data port, two 5 Gbps USB-A ports, and a USB C 100W PD-IN port. Note: The USB C 100W PD-IN port supports only charging and does not support data transfer devices such as headphones or speakers.
  • Powerful Pass-Through Charging: Supports up to 85W pass-through charging so you can power up your laptop while you use the hub. Note: Pass-through charging requires a charger (not included). Note: To achieve full power for iPad, we recommend using a 45W wall charger.
  • Transfer Files in Seconds: Move files to and from your laptop at speeds of up to 5 Gbps via the USB-C and USB-A data ports. Note: The USB C 5Gbps Data port does not support video output.
  • HD Display: Connect to the HDMI port to stream or mirror content to an external monitor in resolutions of up to 4K@30Hz. Note: The USB-C ports do not support video output.
  • What You Get: Anker 332 USB-C Hub (5-in-1), welcome guide, our worry-free 18-month warranty, and friendly customer service.
curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp

The free plan includes 1,000 screenshots a month with no card; paid plans start at $5 for 3,000 screenshots. Sign up for ScreenshotNeo free.

Troubleshoot common failures

Symptom Likely cause What to do
WordPress returns a WP_Error. The HTTP request failed at the transport or safety-validation layer, or timed out. Check that the submitted URL is valid and publicly reachable, retain safe URL handling, and adjust the timeout only to a bounded value appropriate for the route.
The service responds with a non-success status. The remote request was rejected or could not be completed. Check the request URL and screenshot parameters, inspect the response status for logs, and show a graceful preview-unavailable state rather than breaking the page.
JSON decoding fails or screenshot data is missing. The response may not be the expected JSON workflow, or the capture did not yield screenshot data. Confirm that the request did not use direct-image embed mode, validate the decoded structure before indexing it, and handle missing image URLs as a recoverable error.
The rendered img is broken. The stored asset URL may be absent, invalid, or no longer usable. Escape the URL for the HTML attribute, avoid caching malformed results, and permit a later retry after the transient expires or is cleared.
Visitors can trigger too many captures. A public feature lacks suitable access and abuse controls. Restrict generation where possible, enforce rate limits, and cache repeated requests using keys that include capture settings.

Frequently Asked Questions

Does this approach require a WordPress screenshot plugin to already exist?

No. It is an integration pattern for adding screenshot generation to a plugin; it does not rely on a particular existing plugin.

Can I use Microlink without an API key?

Microlink’s screenshot guide currently describes 25 requests per day without an API key; verify its current terms and quota before relying on that allowance.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

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.