The right method depends on what “HTML to an image” means. For a one-time image of an element already visible in a WordPress page, use html2canvas in the browser. For automatic social cards made from post data, use a WordPress integration such as Auto OG Images from html2img. For a hosted URL or HTML snippet, use a shortcode connected to a capture service. These approaches differ in fidelity, cross-origin behavior, automation, and where the resulting file is stored.
Choose the conversion route before writing code
| Goal | Best-fit route | What it does | Main limitation |
|---|---|---|---|
| Export one element that a visitor can see | html2canvas |
Reconstructs a DOM element and CSS into a browser canvas, which you can save as PNG | It is not a native screenshot; unsupported CSS, cross-origin images, and iframes can fail |
| Create an image for every post | Auto OG Images (html2img WordPress integration) | Builds a card from title, author, excerpt, date, and featured image, renders a PNG, and stores it in the Media Library | Designed for Open Graph and social-sharing images rather than every arbitrary HTML document |
| Capture a URL or HTML snippet from WordPress content | GrabzIt Web Capture shortcode | Wraps a URL or snippet in a [grabzit] shortcode and sends it to an external capture service |
Requires an application key and domain authorization |
| Capture a hosted page through an API, with cleanup and automation | ScreenshotNeo | Returns PNG, JPEG, WebP, or PDF from one request and removes common consent banners, popups, and chat widgets before capture | Requires an API key (the free tier does not require a card) |
Do not treat these as interchangeable. A browser library is convenient for an interactive “Download card” button. A post integration is better when every article needs a consistent social image. A hosted API is useful when WordPress should not run a browser at all.
Method 1: Convert a WordPress DOM element with html2canvas
html2canvas accepts a DOM element and returns a Promise that resolves to a canvas. You can append that canvas to the page for inspection or export it with toDataURL('image/png'). Install the package in a custom plugin or theme build:
npm install @html2canvas/html2canvas
Then capture an element after it exists in the DOM:
Quick wins for a faster PC:
Repair Windows errors before they cause bigger problemsFix Now →Fix the driver behind crashes, sound loss and screen glitchesFind Drivers →#1 Best Overall
- CRISP CLARITY: This 23.8″ Philips V line monitor delivers crisp Full HD 1920x1080 visuals. Enjoy movies, shows and videos with remarkable detail
- INCREDIBLE CONTRAST: The VA panel produces brighter whites and deeper blacks. You get true-to-life images and more gradients with 16.7 million colors
- THE PERFECT VIEW: The 178/178 degree extra wide viewing angle prevents the shifting of colors when viewed from an offset angle, so you always get consistent colors
- WORK SEAMLESSLY: This sleek monitor is virtually bezel-free on three sides, so the screen looks even bigger for the viewer. This minimalistic design also allows for seamless multi-monitor setups that enhance your workflow and boost productivity
- A BETTER READING EXPERIENCE: For busy office workers, EasyRead mode provides a more paper-like experience for when viewing lengthy documents
import html2canvas from '@html2canvas/html2canvas';
const element = document.querySelector('#capture');
if (!element) throw new Error('Capture target not found');
const canvas = await html2canvas(element);
const imageData = canvas.toDataURL('image/png');
const link = document.createElement('a');
link.download = 'wordpress-card.png';
link.href = imageData;
link.click();
Enqueue the script in WordPress
WordPress must load your compiled JavaScript on the page where the capture control appears. In a custom plugin, enqueue the bundle and pass its URL:
add_action('wp_enqueue_scripts', function () {
if (!is_page('card-builder')) {
return;
}
wp_enqueue_script(
'my-card-capture',
plugin_dir_url(__FILE__) . 'assets/card-capture.js',
array(),
'1.0.0',
true
);
});
Your markup needs a stable target and a button:
<article id="capture" class="share-card">
<h2><?php the_title(); ?></h2>
<p><?php echo esc_html(get_the_excerpt()); ?></p>
</article>
<button type="button" id="download-card">Download PNG</button>
Bind the button only after the document is ready:
document.addEventListener('DOMContentLoaded', () => {
document.querySelector('#download-card')?.addEventListener('click', async () => {
const target = document.querySelector('#capture');
const canvas = await html2canvas(target);
const link = document.createElement('a');
link.download = 'post-card.png';
link.href = canvas.toDataURL('image/png');
link.click();
});
});
Important html2canvas limitations
- It reconstructs, rather than photographs, the page. The library traverses the DOM and uses CSS properties it understands. Unsupported effects can look different from the live page, so do not promise pixel-perfect output.
- Cross-origin images can taint the canvas. Images generally need to be same-origin or served through an appropriate proxy. A tainted canvas cannot be exported safely.
- Cross-origin iframes are inaccessible. Browser security prevents the script from reading another origin’s frame.
- Wait for assets. Run the capture after fonts, images, and any asynchronous content have loaded. If a card changes after capture starts, the exported image will not contain the later state.
- Control dimensions deliberately. Use a fixed card width and height when a social network requires a predictable aspect ratio. A long article element can create an impractically tall PNG.
When this route is appropriate
Use it for a developer-controlled component whose resources and CSS you can test. It is a poor fit for pages dominated by third-party iframes, remote images without suitable CORS handling, or effects that the library does not support. Treat the output as a rendered representation, not evidence that a real browser screenshot was taken.
Method 2: Automatically generate post and Open Graph images
The documented Auto OG Images integration from html2img is aimed at recurring social-image generation. It builds a card from a post’s title, author, excerpt, date, and featured image, renders a PNG through its service, saves the result to the WordPress Media Library, and emits Open Graph and Twitter image tags. It can pass the image to Yoast SEO, Rank Math, All in One SEO, or SEOPress when one of those plugins is active.
Requirements and setup decisions
- The integration documentation lists WordPress 6.2 or newer and PHP 7.4 or newer.
- An API key is used by administrative or background tasks and is not exposed to the browser.
- A custom template is an HTML document with placeholders. Documented hooks allow developers to change variables, render arguments, designs, dimensions, and whether generation should occur.
- The service documentation reports a one-time free allowance of 50 credits and one credit per render. It also states that generated files are stored in the Media Library by default; free-plan CDN copies last seven days while local copies remain available. These are vendor terms and can change, so confirm them in the plugin’s current documentation before relying on them.
A practical publishing workflow
- Install and activate the integration, then enter its API key in the plugin’s settings.
- Choose or create the HTML template. Keep text areas bounded, provide a fallback for missing featured images, and design for the image dimensions you intend to publish.
- Publish a test post containing a long title, a missing excerpt, and a transparent or unusually cropped featured image.
- Confirm that the PNG appears in Media Library, that the expected Open Graph and Twitter tags are present, and that your SEO plugin is receiving the generated image.
- Decide when regeneration should happen. If a title or featured image changes, stale cards can remain unless the integration’s generation hooks are configured to rerender.
This route is specifically for automated post graphics. It is not automatically the best way to export an arbitrary dashboard, invoice, or interactive block.
Free tools Windows power users keep installed
One-click scans. No signup required.
Rank #2
- CRISP CLARITY: This 22 inch class (21.5″ viewable) Philips V line monitor delivers crisp Full HD 1920x1080 visuals. Enjoy movies, shows and videos with remarkable detail
- 100HZ FAST REFRESH RATE: 100Hz brings your favorite movies and video games to life. Stream, binge, and play effortlessly
- SMOOTH ACTION WITH ADAPTIVE-SYNC: Adaptive-Sync technology ensures fluid action sequences and rapid response time. Every frame will be rendered smoothly with crystal clarity and without stutter
- INCREDIBLE CONTRAST: The VA panel produces brighter whites and deeper blacks. You get true-to-life images and more gradients with 16.7 million colors
- THE PERFECT VIEW: The 178/178 degree extra wide viewing angle prevents the shifting of colors when viewed from an offset angle, so you always get consistent colors
Method 3: Capture a URL or snippet with a WordPress shortcode
GrabzIt Web Capture documents a [grabzit] shortcode that can wrap either a webpage URL or an HTML snippet. The documented setup requires an application key and authorization for your domain. A typical implementation decision is whether the shortcode should display the generated image immediately or defer loading until the external service has completed the capture.
Use a shortcode route when
- The content already has a stable public URL or self-contained HTML snippet.
- You prefer WordPress editor content over custom JavaScript.
- You accept a dependency on an external service and its credentials.
Before deploying, verify the current plugin listing for supported output formats, authentication behavior, limits, and whether captures are generated synchronously or asynchronously. Those details can change and are not universal to every version of the service.
How the three approaches differ
| Decision factor | html2canvas | Auto OG Images | Shortcode capture |
|---|---|---|---|
| Input | DOM element in the visitor’s browser | WordPress post fields and a template | Hosted URL or HTML snippet |
| Rendering model | DOM/CSS reconstruction | Vendor-rendered image using its documented Chrome-based process | External service capture |
| Automation | You implement the button or trigger | Post-oriented generation and Media Library storage | Shortcode-driven workflow |
| Cross-origin concerns | Same-origin/CORS and iframe restrictions apply | Handled outside the visitor’s browser, subject to service rules | Handled by the external service, subject to its authorization rules |
| Best first test | A representative element with every image and font used in production | A post with long and missing fields | A public URL and a minimal snippet |
The vendor description that Auto OG Images uses real Chrome and the html2canvas project’s description of DOM reconstruction are not an independent accuracy benchmark. Test the exact design you plan to publish instead of assuming one is universally more faithful.
Or skip the browser setup: ScreenshotNeo
ScreenshotNeo is a website screenshot API and MCP server for developers. A single GET request can return a PNG, JPEG, WebP, or PDF. Before capture, it accepts common cookie or consent banners and removes more than 60 known consent platforms, newsletter popups, and chat widgets; each cleanup step can be disabled. Bot checks and CAPTCHAs, blank pages, timeouts, failed loads, and cache hits are not billed, and the response identifies the page verdict and billing status in X-Page-Verdict and X-Billed headers.
Recommended Free Tools
It can capture a full page with lazy images loaded, one element by CSS selector, a chosen device or viewport, retina scale, dark mode, PDFs with paper size, margins, orientation and page ranges, HTML/CSS, custom JavaScript, clicks, selector waits, delays, network-idle waits, blocked ads or resource types, custom headers, cookies, user agents, Authorization, timezone, geolocation, transparent backgrounds, resizing, configurable TTL caching, signed links, asynchronous jobs with signed webhooks, bulk capture of up to 100 URLs per call, usage reporting, and an OpenAPI specification. Its parameter names also accept those used by other screenshot APIs, which can simplify migration. An MCP server provides take_screenshot, get_page_info, and capture_pdf tools for Claude, Cursor, and other MCP clients.
Rank #3
- Clear visuals. Fluid motion: A 144Hz refresh rate and 1ms MPRT deliver smooth, tear‑free motion across work, gaming, and streaming for clearer, more fluid viewing.
- Eye comfort: TÜV Rheinland 3‑star* certification reduces harmful blue light while preserving stunning color quality without compromise. *TÜV Rheinland 3-star eye comfort certification.
- Wide viewing angle: Get consistent views across a wide 178° /178° viewing angle.
- In-Plane Switching (IPS): See excellent color accuracy and consistency across wide viewing angles with In-plane Switching (IPS) technology.
- Ultra-thin bezels: Maximize your viewing experience with thin bezels.
Use the ScreenshotNeo documentation for the complete parameter list. The following calls target a page rather than a browser-side DOM node:
cURL
curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp
Python
import requests
r = requests.get("https://api.screenshotneo.com/v1/shot", params={"access_key": "YOUR_API_KEY", "url": "https://stripe.com"}, timeout=90)
r.raise_for_status()
open("shot.webp", "wb").write(r.content)
Node.js
const q = new URLSearchParams({ access_key: 'YOUR_API_KEY', url: 'https://stripe.com' });
const res = await fetch(`https://api.screenshotneo.com/v1/shot?${q}`);
if (!res.ok) throw new Error(`Screenshot failed: ${res.status}`);
const fs = await import('node:fs/promises');
await fs.writeFile('shot.webp', Buffer.from(await res.arrayBuffer()));
Plans and cost
| Plan | Included shots | Price |
|---|---|---|
| Free | 1,000 per month | $0, no card |
| Starter | 3,000 | $5 |
| Growth | 15,000 | $15 |
| Pro | 60,000 | $39 |
| Scale | 250,000 | $99 |
| Business | 1,000,000 | $249 |
Yearly billing gives two months free, and every feature is available on every plan. For an automated WordPress pipeline, pass a stable URL, select the required output format, and inspect the verdict and billing headers before storing the response. If you need a public image element, use a signed link rather than exposing your access key.
Start with 1,000 free screenshots a month, with no card required.
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 matchTroubleshooting conversion failures
The canvas is blank or missing images
Check that the selector matches the rendered element, wait for images and fonts, and test every remote image for same-origin or CORS compatibility. Cross-origin iframes cannot be read by browser JavaScript; replace them with same-origin content or use a server-side capture route.
Rank #4
- CURVED FOR ENHANCED ENGAGEMENT: An immersive viewing experience with a curved monitor that wraps more closely around your field of vision; It creates a wider view, enhancing depth perception and minimizing peripheral distraction
- SMOOTH PERFORMANCE FOR SEAMLESS CONTENT: Stay in the action when playing games, watching videos, or working on creative projects; The 100Hz refresh rate reduces lag and motion blur so you don't miss a thing in fast-paced moments¹
- MORE GAMING POWER: Gain the edge with optimizable game settings; Color and image contrast can be adjusted to see scenes more vividly and spot enemies hiding in the dark; Game Mode adjusts any game to fill the screen so you can view every detail²
- KEEP IT EASY ON THE EYES: Care for your eyes and stay comfortable, even during long sessions; Advanced eye comfort technology certified by TÜV reduces eye strain by minimizing blue light and reducing irritating screen flicker²
- INCREASED VERSATILITY: Connect to more; Plug devices straight into your monitor for increased flexibility, making your computing environment even more convenient
toDataURL throws a security error
A remote image likely tainted the canvas. Configure an appropriate proxy or serve the asset from the same origin. Do not attempt to work around browser origin rules by exposing private credentials in front-end code.
The output differs from the page
That is expected when CSS is unsupported by the reconstruction library. Remove or simplify effects that are not reproduced, or move the capture to a real-browser service and compare the result against the required design.
The WordPress button does nothing
Open the browser console, verify that the bundle loaded, and confirm that the script runs after the target element exists. In WordPress, check that the enqueue condition matches the actual page slug or post type and that another script has not stopped execution earlier.
The automatic social image is stale
Check the integration’s generation decision and rerender hooks. Confirm that the new PNG is attached in Media Library and that your SEO plugin is not outputting an older manually selected image.
Best Value
- 【INTEGRATED SPEAKERS】Whether you're at work or in the midst of an intense gaming session, our built-in speakers provide rich and seamless audio, all while keeping your desk clutter-free.
- 【EASY ON THE EYES】 Protect your eyes and enhance your comfort with Blue-Light Shift technology. This feature reduces harmful blue light emissions from your screen, helping to alleviate eye strain during long hours of use and promoting healthier viewing habits.
- 【WIDEN YOUR PERSPECTIVE】Our sleek minimal bezel design ensures undivided attention. The nearly bezel-free display seamlessly connects in a dual monitor arrangement, delivering an unobstructed view that lets you focus on more at once, completely distraction-free.
A shortcode image never appears
Verify the application key, authorized domain, shortcode syntax, and the external service’s current status and output rules. Test with a simple public URL before adding complex HTML.
An API capture returns an error or an unexpected bill
Inspect the HTTP status and the X-Page-Verdict and X-Billed headers. A failed load, bot check, blank page, timeout, or cache hit is not billed by ScreenshotNeo; a successfully rendered page is a clean shot and can be billed according to your plan. For other services, consult their current terms because billing and failure handling differ.
Performance, reliability, and security checklist
- Use fixed dimensions for repeatable social cards and avoid exporting an entire article when only a card is needed.
- Capture after asynchronous data, web fonts, and lazy images are ready; otherwise the image can be incomplete.
- Keep API keys on the server or in protected WordPress settings. Never place a service key in browser JavaScript.
- Cache deterministic images and regenerate only when the source title, excerpt, featured image, or template changes.
- Test long titles, missing fields, right-to-left text, dark mode, high-density screens, slow connections, and blocked third-party resources.
- Store the generated file with a meaningful name and verify its MIME type before inserting it into post metadata.
- For consent, privacy, or authenticated pages, review whether the capture is allowed and whether cookies or Authorization headers expose personal data.
Which method should you use?
- Choose html2canvas for an interactive, browser-side export of a controlled element and when you can accept DOM/CSS reconstruction.
- Choose Auto OG Images when every WordPress post needs a generated PNG in Media Library with social metadata.
- Choose a shortcode capture plugin when editors need to insert a URL or snippet and an external service credential is acceptable.
- Choose ScreenshotNeo when you want an API or MCP workflow, real page capture without browser setup, cleanup of consent banners and widgets, and billing that excludes failed or unusable captures.
Frequently Asked Questions
Can WordPress convert HTML to an image without JavaScript in the visitor’s browser?
Yes. A server-side integration or hosted capture API can render a URL or template without running html2canvas in the visitor’s browser. The trade-off is an external service or server process instead of a local canvas export.
Should I save the image as PNG, JPEG, or WebP?
Use PNG for text-heavy cards or transparency, JPEG for photographic images where a smaller file is more important, and WebP when your delivery stack and target platforms support it. Test the actual social networks and email clients that will consume the file.
Can these methods capture a private WordPress draft?
Only if the renderer can authenticate safely, for example with protected server-side credentials or an authorized session. Do not put draft credentials or API keys in front-end JavaScript, and review the service’s data-handling terms before sending private content.
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.

