Chart featured-image PNGs are captured through Screenshot_Service. Callers keep is_configured() and take(). Providers share one capture spec. Administrators set the provider and capture defaults under Charts → Settings → Screenshot Settings. That pane shows a configured / not-configured badge and lists the VIP API key constants as set or not set. Credential values are never returned. Firebase lists PRC_PLATFORM_FIREBASE_KEY, PRC_PLATFORM_FIREBASE_PROJECT_ID, and whether the service-account file from PRC_PLATFORM_FIREBASE_SERVICE_ACCOUNT is present.
Pipeline
-
Save or regenerate
PNG_Exportenqueues an Action Scheduler job. The featured-image path callstake()with the saved chart layout and the site screenshot defaults (scale, padding, selector, delay). -
Resolve a provider
The registry uses
PRC_PLATFORM_CHART_SCREENSHOT_PROVIDERwhen that constant is set. Otherwise it uses the provider saved in Charts → Settings. If both are empty it auto-detects the first configured provider in order: ScreenshotOne, Cloudflare, Firebase, signed endpoint. -
Capture /export/
The provider screenshots
{permalink}/export/. That page renders only the chart. It always uses desktop attributes. Explicittake_spec()calls addscreenshot_widthandscreenshot_heightso the chart reflows first. Successful captures store the provider slug on the attachment.
PNG_Export does not generate extra sizes on save. Extra frames are later callers of take_spec().
Capture spec
Screenshot_Capture_Spec is the input every provider must honor.
Screenshot_Capture_Spec
-
viewport_widthnumber required -
Browser CSS viewport width in pixels, including side padding when built from layout.
-
viewport_heightnumber required -
Browser CSS viewport height in pixels, including side padding when built from layout.
-
device_scale_factornumber required -
Positive integer. Default featured-image capture uses 2.
-
selectorstring -
CSS selector captured by the provider.
-
delay_secondsnumber -
Wait before capture so the charting library can render.
-
viewport_side_paddingnumber -
Padding added on each side when building from layout or an alias. Default featured-image padding is 48. Export reflow uses the unpadded layout size.
No fields match this filter.
take( $url, $width, $height ) builds from_layout() using Charts → Settings capture defaults and does not add export query args. take_spec( $url, $spec ) appends screenshot_width and screenshot_height from get_layout_width() / get_layout_height().
$spec = new \PRC\Platform\Chart_Builder\Screenshot_Providers\Screenshot_Capture_Spec( 1200, 400, 3);$png = ( new \PRC\Platform\Chart_Builder\Screenshot_Service() ) ->take_spec( $export_url, $spec );
Export page
URL pattern: /chart/{slug}/export/.
Query args screenshot_width and screenshot_height must both be present, must be positive integers, and are capped at 2000 to match the Firebase screenshotElement viewport limit. Incomplete or invalid values keep the saved layout. The page body class is wp-chart-builder-export. Chart view JS locks that document to the desktop attribute set so a 640px chart is not treated as tablet.
Named aliases
Screenshot_Capture_Spec::from_alias( $slug, $chart_width, $chart_height ) resolves default to from_layout(). Any other slug comes from prc_chart_builder_screenshot_variants. The plugin registers no extra aliases.
Each filtered variant must include integer width, height, scale, and padding. Unknown slugs return screenshot_variant_not_found. Malformed variants return screenshot_variant_invalid.
add_filter( 'prc_chart_builder_screenshot_variants', static function ( $variants ) { $variants['wide'] = array( 'width' => 1200, 'height' => 400, 'scale' => 2, 'padding' => 48, ); return $variants; });
Provider setup
Pin a slug with PRC_PLATFORM_CHART_SCREENSHOT_PROVIDER (screenshotone, cloudflare, firebase, or endpoint). That constant locks the settings UI. When the constant is empty, the site option from Charts → Settings → Screenshot Settings is used. Leave both empty to auto-detect. Filter prc_chart_builder_screenshot_provider runs after the constant and the setting. Filter prc_chart_builder_screenshot_providers can replace the registry.
Successful featured-image captures write _prc_chart_screenshot_provider on the attachment. The media modal shows that field.
VIP constants
-
PRC_PLATFORM_CHART_SCREENSHOT_PROVIDERstring -
Optional provider slug. Empty string selects auto-detect.
-
PRC_PLATFORM_SCREENSHOTONE_ACCESS_KEYstring -
ScreenshotOne access key. Required with the secret for the screenshotone provider.
-
PRC_PLATFORM_SCREENSHOTONE_SECRET_KEYstring -
ScreenshotOne secret key.
-
PRC_PLATFORM_CLOUDFLARE_ACCOUNT_IDstring -
Cloudflare account id for Browser Rendering.
-
PRC_PLATFORM_CLOUDFLARE_BROWSER_RENDERING_API_TOKENstring -
Cloudflare API token with Browser Rendering screenshot permission.
-
PRC_PLATFORM_CHART_SCREENSHOT_ENDPOINT_URLurl -
Signed HTTP screenshot endpoint URL.
-
PRC_PLATFORM_CHART_SCREENSHOT_ENDPOINT_KEYstring -
API key sent to the signed HTTP endpoint.
No fields match this filter.
ScreenshotOne
Default auto-detect provider. Uses the ScreenshotOne PHP SDK. Configured when both access and secret keys are non-empty. Maps selector, delay, viewport, format PNG, and deviceScaleFactor.
Cloudflare Browser Rendering
REST wp_remote_post to Cloudflare’s screenshot API. Configured when account id and Browser Rendering token are non-empty. Timeout is 60 seconds. Success bodies are PNG. JSON error envelopes become WP_Error.
Firebase screenshotElement
Uses the existing Print Engine render function, not a second Puppeteer service. Configured when PRC\Platform\Firebase exists and prc_platform_firebase_render_endpoints includes screenshot_element (URL from PRC_PLATFORM_FIREBASE_PROJECT_ID). Auth is an OIDC ID token minted from the service-account file (PRC_PLATFORM_FIREBASE_SERVICE_ACCOUNT). The Firebase constructor also requires PRC_PLATFORM_FIREBASE_KEY. The function must honor viewportWidth, viewportHeight, and deviceScaleFactor.
Signed HTTP endpoint
Generic image/png backend for Cloud Run or Lambda. Configured when URL and API key constants are set.
Errors
Screenshot_Service::take() / take_spec() return screenshot_service_not_configured when no provider resolves. REST POST /chart/{id}/regenerate-png maps that to HTTP 503 with the same code. Provider-specific codes stay on that provider.
Source:
includes/class-screenshot-service.phpincludes/screenshot-providers/includes/settings/class-screenshot-settings.phpincludes/class-chart-export-endpoint.phpincludes/class-png-export.php