ScreenshotNeo

BlogHow-to

PHP Link Directory Screenshot Processor: Setup and Use

There is no confirmed built-in phpLD screenshot processor. Learn how to verify your version and add cached website preview thumbnails with a separate capture service.

By the ScreenshotNeo team4 October 202610 min read

Direct answer: The available documentation does not confirm a built-in feature or standalone product called “PHP Link Directory Screenshot Processor.” If your goal is to show website preview thumbnails beside directory listings, treat that as a separate integration: request a screenshot from a capture service, store or cache the resulting image, and associate it with the listing. First identify your phpLD version and any plugin or processor package you have; do not assume instructions for one release apply to another.

This guide covers how to identify the software, plan a screenshot-thumbnail integration, and implement one with PHP and a screenshot API. The API example is an independent integration pattern, not an official phpLD feature or a claim of compatibility with a particular phpLD release.

1. Identify the phpLD version and processor

“PHP Link Directory” can refer to different generations of software. The legacy Version 5 manual and the current PHPLD Next feature page describe different installation paths. The reviewed PHPLD Next feature page lists directory functions but does not document automatic screenshot generation. The official support page also does not identify a screenshot processor.

  • Using Version 5? Its manual describes uploading and unpacking the application, renaming /include/config.php.new to /include/config.php, setting permissions, preparing a database, and completing the browser installer. These are legacy, version-specific instructions. Check the exact package and server before applying them.
  • Using PHPLD Next? Its official feature page describes a browser installer that requests database details, administrator credentials, and basic site settings. Check the current product page and package because release behavior can change.
  • Using a separate processor or plugin? Record its name, version, download source, and documented phpLD compatibility. If these are unknown, ask the package provider before installing it or changing the directory schema.

For the legacy installer steps, use the PHP Link Directory Version 5 manual. For current product information, see the PHPLD Next feature page and official support page.

2. Choose how to generate thumbnails

The thumbnail workflow has three parts: capture a submitted site, keep the resulting image available, and render it with the corresponding directory listing. A third-party tutorial demonstrates using a screenshot API and caching the result for a PHP link directory. It does not establish an official integration or compatibility with a particular phpLD release.

Approach What you operate Considerations
Screenshot API Your PHP integration plus the provider’s remote capture service Less browser infrastructure to manage. Check current API parameters, limits, authentication, retention, and terms.
Self-hosted browser A browser runtime, its dependencies, queueing, storage, and maintenance More control over the runtime, with more deployment and reliability work. The cited tutorial mentions this as an alternative but does not prescribe a particular browser setup.

Before choosing, decide when captures run, how long thumbnails remain cached, how failures are retried, and what image dimensions and format your listing page needs. Do not capture every page view: generate on submission or through a background job, then reuse the saved image.

3. Define the data and capture flow

  1. Validate and normalize the submitted destination URL. Allow only the schemes your directory supports, typically HTTP or HTTPS.
  2. Create or update the directory listing with a capture status such as pending.
  3. Enqueue a capture job. Avoid making the public submission request wait for a remote browser to finish.
  4. Have a worker request the screenshot and verify that the response is an image before saving it.
  5. Store the image in your chosen filesystem or object store and save its path, capture time, and status against the listing.
  6. Render the stored thumbnail on the listing page. If capture fails, show a neutral placeholder and allow a later retry.
  7. Refresh thumbnails on a deliberate schedule or when the destination URL changes, rather than on every page view.

The storage and database fields depend on your installation. Use the extension mechanism documented for your exact phpLD release; avoid editing core files or assuming a table name based on another version.

4. PHP example: request and cache a screenshot

This standalone PHP example calls a screenshot API, checks the HTTP response and content type, and writes the image to a cache directory. It demonstrates the capture portion only; adapt the queue, storage, and listing update to your application. It does not establish a phpLD plugin or release-specific integration.

<?php
declare(strict_types=1);

$targetUrl = 'https://example.com/';
$accessKey = getenv('SCREENSHOTNEO_API_KEY');
$cacheDir = __DIR__ . '/var/site-thumbnails';

if (!$accessKey) {
    throw new RuntimeException('Set SCREENSHOTNEO_API_KEY before running this script.');
}

if (!filter_var($targetUrl, FILTER_VALIDATE_URL)) {
    throw new InvalidArgumentException('The target URL is not valid.');
}

$parts = parse_url($targetUrl);
if (!in_array(strtolower($parts['scheme'] ?? ''), ['http', 'https'], true)) {
    throw new InvalidArgumentException('Only HTTP and HTTPS URLs are allowed.');
}

if (!is_dir($cacheDir) && !mkdir($cacheDir, 0750, true) && !is_dir($cacheDir)) {
    throw new RuntimeException('Could not create thumbnail cache directory.');
}

$cacheName = hash('sha256', $targetUrl) . '.webp';
$cachePath = $cacheDir . DIRECTORY_SEPARATOR . $cacheName;

$query = http_build_query([
    'access_key' => $accessKey,
    'url' => $targetUrl,
]);
$endpoint = 'https://api.screenshotneo.com/v1/shot?' . $query;

$ch = curl_init($endpoint);
curl_setopt_array($ch, [
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_FOLLOWLOCATION => false,
    CURLOPT_CONNECTTIMEOUT => 10,
    CURLOPT_TIMEOUT => 90,
    CURLOPT_HEADER => true,
]);
$response = curl_exec($ch);
if ($response === false) {
    $message = curl_error($ch);
    curl_close($ch);
    throw new RuntimeException('Screenshot request failed: ' . $message);
}

$status = (int) curl_getinfo($ch, CURLINFO_RESPONSE_CODE);
$headerSize = (int) curl_getinfo($ch, CURLINFO_HEADER_SIZE);
$contentType = (string) curl_getinfo($ch, CURLINFO_CONTENT_TYPE);
curl_close($ch);

$body = substr($response, $headerSize);
if ($status < 200 || $status >= 300) {
    throw new RuntimeException('Screenshot API returned HTTP ' . $status);
}
if (stripos($contentType, 'image/') !== 0) {
    throw new RuntimeException('Expected an image response; received ' . $contentType);
}
if ($body === '') {
    throw new RuntimeException('Screenshot API returned an empty response body.');
}

if (file_put_contents($cachePath, $body, LOCK_EX) === false) {
    throw new RuntimeException('Could not write screenshot to cache.');
}

// In a queued integration, persist $cacheName and a successful capture status
// against the listing here. Serve the image through your application or a
// controlled static-media path.
echo $cachePath . PHP_EOL;

Set SCREENSHOTNEO_API_KEY in the worker environment rather than committing it to source control. In a production integration, also enforce your own outbound URL policy, limit concurrent jobs, and record the provider response status needed for support and retries.

5. cURL, Python, and Node.js alternatives

These snippets show the same API request from other runtimes. Each writes or receives the image response; production code should validate status and content type before storing it. See the ScreenshotNeo API documentation for the request options.

cURL

curl -G "https://api.screenshotneo.com/v1/shot" \
  -d access_key=YOUR_API_KEY \
  --data-urlencode url=https://example.com \
  -o thumbnail.webp

Python

import os
import requests

api_key = os.environ["SCREENSHOTNEO_API_KEY"]
r = requests.get(
    "https://api.screenshotneo.com/v1/shot",
    params={"access_key": api_key, "url": "https://example.com"},
    timeout=90,
)
r.raise_for_status()
content_type = r.headers.get("Content-Type", "")
if not content_type.startswith("image/"):
    raise RuntimeError(f"Expected an image response, received {content_type}")
with open("thumbnail.webp", "wb") as image_file:
    image_file.write(r.content)

Node.js

const q = new URLSearchParams({
  access_key: process.env.SCREENSHOTNEO_API_KEY,
  url: 'https://example.com',
});
const res = await fetch(`https://api.screenshotneo.com/v1/shot?${q}`, {
  signal: AbortSignal.timeout(90000),
});
if (!res.ok) throw new Error(`Screenshot API returned HTTP ${res.status}`);
const contentType = res.headers.get('content-type') || '';
if (!contentType.startsWith('image/')) {
  throw new Error(`Expected an image response, received ${contentType}`);
}
const image = Buffer.from(await res.arrayBuffer());
await import('node:fs/promises').then(fs => fs.writeFile('thumbnail.webp', image));

6. Store and serve thumbnails safely

  • Use a stable cache key. A hash of the normalized URL avoids unsafe path characters. Include capture settings in the key if they affect the resulting image.
  • Keep API credentials private. Make the request from a server-side worker. Never put a secret access key in browser JavaScript or a public image URL.
  • Validate destinations. A user-submitted URL can point to internal services or sensitive network addresses. Apply an outbound URL policy and provider-side controls appropriate to your environment; reject local, private, and unsupported destinations.
  • Validate responses. Check HTTP status, content type, and nonzero body length. If your media pipeline supports it, inspect the actual image and enforce a size limit before publishing it.
  • Separate originals from public media. Use generated filenames and serve thumbnails from a controlled media path. Do not let a submitted URL determine a local filename.
  • Track state. Store pending, complete, and failed outcomes plus a last-attempt time. This makes retries bounded and prevents repeated work on every page load.

7. Capture options and refresh policy

Screenshot providers differ. Confirm which controls your chosen service supports and check its current documentation before relying on a parameter. Common decisions for directory thumbnails include:

Decision When it matters
Viewport or device preset Use a consistent viewport so directory cards have comparable previews.
Full page or viewport Full-page images can be tall and heavy; a viewport capture is often easier to fit into a listing card.
Image format and scale Choose a format and dimensions supported by your serving pipeline and target browsers; avoid retaining oversized files for small cards.
Wait condition Some sites render after client-side scripts. A selector or bounded wait can help, but long waits increase job duration.
Cookies and page state Some destinations block or alter content based on consent or session state. Capture behavior depends on provider support and the target page.
Cache lifetime Refresh when the destination changes or after a chosen age. A long lifetime saves work; a short one reflects updates sooner.

Use a bounded retry policy for temporary failures, with backoff and a maximum number of attempts. Do not retry a permanent invalid URL indefinitely. Keep the previous successful thumbnail while a refresh is pending so a temporary capture failure does not remove a working preview.

8. Performance, reliability, and cost

  • Keep capture off the request path. Browser rendering is slower and less predictable than a database write. Queue capture work and return the directory submission response promptly.
  • Limit parallel work. Cap worker concurrency to protect your PHP application, storage, and any API quota. Process large backlogs in batches.
  • Reuse cached images. Serve the stored thumbnail to visitors; do not make a screenshot request for every directory page view.
  • Plan for unavailable destinations. A site can time out, deny automated access, or return an unusable page. Keep a placeholder and record failure state so the rest of the directory continues to work.
  • Control image storage. Set a retention and refresh policy, choose dimensions appropriate to the UI, and remove stale files when listings are deleted or URLs change.
  • Estimate cost from captures, not page views. Count initial captures and scheduled refreshes, then check the chosen provider’s current pricing and billing rules. The reviewed phpLD sources provide no screenshot-processor price or usage figure.

9. Troubleshooting

Symptom Likely cause Fix
No screenshot processor appears in the admin The title refers to a generic integration, or the installed release does not include that component. Check the exact phpLD version, package contents, and plugin documentation. Do not assume the feature is native.
Legacy installation steps do not match the current package Version 5 instructions are being applied to a different generation. Use the instructions for the exact release; the PHPLD Next page describes a different browser-based installer.
API request returns an error Missing or invalid key, malformed query, provider rejection, or an unsupported destination. Check the server-side key configuration, URL encoding, HTTP status, and current API documentation. Do not log the secret.
Saved file is empty or not an image The response may contain an error body, a failed capture result, or an unexpected content type. Check status and content type before writing; record a redacted diagnostic and handle the failure state.
Submission requests take too long The capture runs synchronously while the user waits. Move capture to a background queue and show a pending state in the directory.
Every page view creates new captures The page renderer requests screenshots instead of serving a stored thumbnail. Persist the image path and reuse it. Refresh only according to a deliberate TTL or URL-change policy.
Thumbnail files are missing after deployment The worker and web process use different storage paths, or the directory is not writable. Use shared storage or a consistent media store, verify ownership and permissions, and keep generated files outside deploy-cleaned temporary directories.
Capture jobs never finish Unbounded waits, stalled workers, or missing timeout handling. Set connection and overall timeouts, monitor queue age, and mark exhausted attempts as failed for later inspection.

10. Or skip the browser setup

If you want the thumbnail capture handled through an API, ScreenshotNeo provides a website screenshot API and an MCP server. One GET request can return an image or PDF. This example saves a screenshot response:

curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp

See the ScreenshotNeo API documentation for options and response details. Its capture can accept cookie and consent banners and remove more than 60 known consent platforms, newsletter popups, and chat widgets before the shot; each step can be turned off. Bot checks, blank pages, failed loads, timeouts, and cache hits cost nothing, and response headers identify the page verdict and billing status. An MCP server provides take_screenshot, get_page_info, and capture_pdf tools for Claude, Cursor, and other MCP clients. The Free plan includes 1,000 screenshots per month with no card; paid plans start at $5 for 3,000 screenshots.

Sign up free for 1,000 screenshots a month, with no card required.

FAQ

The reviewed documentation does not confirm a built-in feature by that name. Identify the exact release and processor package before following setup instructions.

Does this example install a phpLD plugin?

No. It demonstrates a standalone screenshot request and cache write. Integrate it through the extension points supported by your specific installation.

Can I use the legacy Version 5 manual for PHPLD Next?

Do not assume so. The manual is version-specific, and PHPLD Next describes a separate browser installer. Check the current package instructions.

Should the screenshot be generated when a visitor opens a directory page?

Usually, generate or refresh it asynchronously and serve the saved image to visitors. This avoids tying page rendering to a remote capture.

Sources