Skip to content

For developers

Works with your theme. Even better with a line of PHP.

Images from wp_get_attachment_image(), srcset, your content and the block editor go through Focalio automatically. When you want full control, the helpers are there.

Focalio needs PHP 8.3 or newer, WordPress 6.2 or newer, and the Imagick or GD extension.

Without writing code

Install Focalio and your theme's images are already served by it, cropped on the focal point you chose in the Media Library.

  • wp_get_attachment_image(), the_post_thumbnail() and srcset: every size comes from Focalio, on demand.
  • Images in posts and pages, when they show the attachment. An image block with an aspect ratio gets a real crop on the focal point.
  • Cover and Media & Text blocks: their image position follows the focal point.
  • The block editor: a Focalio panel for the Image block, a Cover with an image background and Media & Text with an image. On WordPress 7.1 the editor's own Crop buttons open Focalio's editor.
Nothing to changesingle.php
<?php
the_post_thumbnail('large');
echo wp_get_attachment_image($id, 'medium_large');

In WordPress

What Focalio adds to the WordPress admin, and below it what Focalio Pro adds to the same screens.

Focalio's Edit image window: a photo of an astronaut with the focal point on the helmet, and Rotate, Flip, Focal point and Crops in the sidebar.
Edit imageClick or drag in the image to set the focal point; Centre puts it back in the middle. Rotate by quarter turns and flip, without touching the file. Reset all undoes everything.
The Focalio box on an image's edit screen: a thumbnail with the focal point, its position, and the buttons Edit and Preview crops.
The Focalio boxOn the attachment screen, and the same in the Media Library's details: the focal point, Edit and Preview crops. On the attachment screen, Update saves it.
The crop preview: the same photo as thumbnail, in its original ratio, as hero, card and portrait, the astronaut in frame in each.
Preview cropsOne tile per ratio of the WordPress sizes and presets (up to 12), each cut on the focal point, before you save.
Focalio's Settings tab: image quality 82, output format, maximum width 2560, LQIP by default, crop fallback and image sizes on upload.
SettingsImage quality (82 by default), output format (WebP or AVIF), maximum width, the blurred placeholder for every image (off by default), the crop fallback for images without a focal point (centre by default, or entropy or attention) and skipping image sizes on upload.
Focalio's Presets tab: WordPress sizes to turn on or off, the presets hero 21:9, card 4:3 and portrait 4:5 with quality and LQIP, and the presets registered in code.
PresetsTurn off the WordPress sizes the site doesn't use, and add presets with a ratio, a quality and LQIP of their own. Presets registered in code are listed below them, read-only.

With Focalio Pro Pro

The same screens with Pro active: a few extra controls where you set the focal point, and tabs and settings of its own.

The Edit image window with Pro: a frame with corner handles over the photo, a ruler from −45° to 45° under it, and in the sidebar Zoom, Detect faces and the history: a later version to go forward to, the current one, an earlier one and the original, each with a thumbnail.
Edit image, with ProZoom in on the focal point up to 3× with the slider or the frame's corner handles, straighten with the ruler under the image (up to 45°), and Detect faces. Every change goes into the image's history in the sidebar: each version with a thumbnail, who made it and what it was. Restore an earlier one and the later ones stay, to go forward to again, like undo and redo.
The crop preview with Pro: the focal point in its title, and Adjust crop under the thumbnail, hero, card and portrait tiles.
Preview crops, with ProThe same tiles, with Adjust crop under every ratio of a WordPress size or preset: the thumbnail, hero, card and portrait here. The original ratio is never cut, so it has none.
The Focalio box with Pro: Edit, Preview crops, Detect faces and the link History (2 earlier, 1 later).
The Focalio box, with ProDetect faces puts the focal point on the faces. With the watermark on, No watermark on this image; once there is history, a link that opens the editor on it.
The Crop for card window: a 4:3 frame drawn over the photo, the result next to it, its size in pixels and a zoom slider.
A crop of your ownEach tile of the crop preview gets Adjust crop: draw the frame for that one ratio, and the focal point still decides every other one.
The Settings tab with Pro: AVIF with WebP fallback among the output formats, and the rows Faces and Watermark.
Settings, with ProAVIF with WebP as fallback, faces on upload (the focal point on the faces in every new image) and the watermark, with its image, position, size, opacity and margin.
The Cache tab with Pro: the image cache, Cache warm-up with Every page and Every image, and Warm automatically for changed images.
Cache warm-upRender every page's images and every preset ahead of the first visitor, and render a changed image again by itself after an upload or an edit.
The Import / export tab: Download settings, and an import from a file or pasted text with Check first.
Import / exportDownload the settings as a file and import them on another site; Check first shows what would change. The sign key and the cache never go along.
Focalio across the network: every site with its cache and warm-up, Warm up every site, and a template site for new sites.
Across the networkOn a multisite, every site on one screen with its cache and warm-up, and a template site whose settings new sites start with, or that you copy to every site at once.

The photo: Bruce McCandless II on the first untethered spacewalk, 1984. NASA, public domain.

1 of 13

Focalio's Edit image window: a photo of an astronaut with the focal point on the helmet, and Rotate, Flip, Focal point and Crops in the sidebar.

Edit imageClick or drag in the image to set the focal point; Centre puts it back in the middle. Rotate by quarter turns and flip, without touching the file. Reset all undoes everything.

In templates

glide_image() renders a responsive <img> for any ratio: srcset, lazy loading, and a blurred placeholder if you want one.

Named arguments use the parameter names as they are in PHP: maxWidth:, not max_width:. The helpers start with glide_ and some filters with wp_glide/: names from before Focalio had its name, kept so existing code keeps working.

In a templatesingle.php
<?php
echo glide_image(
    get_post_thumbnail_id(),
    '16:9',
    lazy: false,
    priority: true,
);

Parameters glide_image()

$imageint|array|string|null
Attachment ID or ACF image array (with its focal point, alt text and placeholder), a path relative to the uploads folder or an uploads URL (as it is). null gives an empty string.
$aspectstring
The ratio as W:H, like 16:9, or the name of a preset.
$class?string = null
The class attribute of the <img>.
$maxWidth?int = null
The largest width in the srcset: lower than the Maximum width setting if you like, never above it or the original's.
$sizes?string = null
The sizes attribute. By default 100vw.
$lazybool = true
loading="lazy" and decoding="async". Turn it off for the largest image at the top of the page.
$prioritybool = false
fetchpriority="high", for that same image.
$quality?int = null
Image quality, up to 100. By default the preset's quality, else the site's.
$lqip?bool = null
The blurred placeholder while loading. null follows the preset, else the site. For attachment IDs and ACF image arrays.

An aspect that is neither W:H nor a preset throws an InvalidArgumentException; so does a 0 in the ratio, and preset names are case-sensitive. A missing image gives an empty string, whatever the aspect.

glide_source() gives the <source> for a <picture>, to show another ratio on small screens.

Art directionsingle.php
<picture>
    <?= glide_source($id, '1:1', media: '(max-width: 767px)') ?>
    <?= glide_image($id, '16:9', 'w-full') ?>
</picture>

glide_url() returns just the address of a rendition, or null for a missing image. With fit=crop it crops an attachment ID on the focal point. glide_placeholder() returns the blurred placeholder as a data URI, or null.

Just the URLsingle.php
<?php
$url = glide_url($id, ['w' => 600, 'h' => 600, 'fit' => 'crop']);
$blur = glide_placeholder($id, '1:1');

Presets

Name a ratio once, with its own quality and placeholder, and templates stay short. Register it in your theme's functions.php or a plugin, or add it under Focalio, Presets in the admin.

A preset has an aspect ratio, a quality (40 to 100; leave it out for the site's setting) and a placeholder setting (true, false, or null to follow the site). Names are lowercase letters, digits, - and _, up to 32 characters, starting and ending with a letter or digit; capitals and spaces become lowercase and hyphens.

Register a presetfunctions.php
<?php
glide_register_preset('hero', '21:9', quality: 80, lqip: true);

Use it by name in glide_image() and glide_source(), or as a WordPress image size: in wp_get_attachment_image(), in the block editor's resolution menu and in ACF. No files are written for it.

Use it by namesingle.php
<?php
echo glide_image($id, 'hero');
echo wp_get_attachment_image($id, 'hero');

The same with a filter, if you prefer it. Presets from code win over the ones made in the admin.

Or with a filterfunctions.php
add_filter('wp_glide/register_presets', function (array $presets): array {
    $presets['hero'] = ['aspect' => '21:9', 'quality' => 80];
    return $presets;
});

WP-CLI

Look into the image cache, clean it up or empty it, and work out focal points in bulk.

wp focalio cache stats
How many rendered images are in the cache, and how many the cleanup would remove.
wp focalio cache cleanup [--dry-run]
Run the weekly cleanup now; with --dry-run it only counts. It stops after 20 seconds: run it again for the rest.
wp focalio cache clear [--yes]
Delete every rendered image. Asks first, unless you add --yes. Your originals are never touched.
wp focalio guess [--force]
Work out the automatic focal point (entropy or attention, as set) of every image ahead of time; --force redoes the ones already known. Not when the automatic point is set to the centre.
From the command lineterminal
$ wp focalio cache stats
$ wp focalio cache cleanup --dry-run
$ wp focalio cache clear --yes
$ wp focalio guess --force

Configuration

The settings have filters, for when a value belongs in code. A few useful ones:

Adjust a defaultfunctions.php
add_filter('wp_glide/max_width', fn () => 1920);
add_filter('focalio/cache_max_age_days', fn () => 90);
FilterDefaultWhat it does
wp_glide/max_width2560The largest width in a srcset: the Settings tab's value
wp_glide/quality82Image quality: the Settings tab's value, 82 out of the box
wp_glide/format'webp'webp or avif: the Settings tab's value
wp_glide/default_formatThe format added to an address that asks for none ($path); '' keeps the source's. Animated GIFs always keep theirs
wp_glide/lqipfalseBlurred placeholders across the site: the Settings tab's value
wp_glide/route_prefix'img'The first part of image addresses (/img/…)
wp_glide/cache_pathuploads/.glide-cacheWhere rendered images are kept
wp_glide/driver'imagick' | 'gd'imagick, else gd
focalio/image_paramsThe last word on an image's parameters (array $params, int $id, ?array $transform, string $context)
focalio/cache_max_age_days180Days before the weekly cleanup removes a rendered image; 0 keeps them
focalio/virtual_sizes_keep['thumbnail']Sizes still saved on upload when Image sizes on upload is on
focalio/early_servetrueServe cached images before WordPress loads; false from a must-use plugin, like FOCALIO_EARLY_SERVE
focalio/replace_image_editortrueOn WordPress 7.1, the block editor's Crop buttons open Focalio's editor; false gives back WordPress's own

Image addresses are signed, so nobody can ask your server for any size they like: a wrong signature gets a 403. Focalio makes the key itself. Define GLIDE_SIGN_KEY to keep it the same across environments; Focalio, Security shows the line to paste.

Focalio serves images it has already made before WordPress loads, which is what makes them fast. FOCALIO_EARLY_SERVE set to false turns that off: in wp-config.php or a must-use plugin, because it's read while plugins load. The focalio/early_serve filter does the same.

In wp-config.phpwp-config.php
define('GLIDE_SIGN_KEY', 'your-own-long-random-key');
define('FOCALIO_EARLY_SERVE', false);

What Pro adds Pro

Focalio Pro is an add-on to the plugin above. Your templates stay as they are: Pro adds to what they render. It comes with a licence, not as a download from this site.

  • Zoom, straighten and a crop of your own per ratio, set per image in the Media Library. glide_image(), glide_url() and wp_get_attachment_image() follow them by themselves. In glide_url(), a crop you pass yourself (crop-x-y-zoom) is left alone, and passing st or mark leaves out the straightening or the watermark.
  • Version history per image: every change to the focal point, orientation, zoom, angle, crops and watermark choice, the last 20, with a thumbnail each. Go back and forward, like undo and redo.
  • AVIF with WebP as a fallback: images in your content and from wp_get_attachment_image() get a <picture> with AVIF. glide_image() and glide_source() keep giving WebP.
  • A watermark from the Media Library: one of nine positions, a size, an opacity and a margin, left off small images. Leave it off per image or per preset.
  • Changed images are rendered again by themselves: after an upload, or when the focal point, orientation, zoom, angle, a crop or the watermark changes. New uploads get their focal point on the faces.
  • Four WP-CLI commands: render the cache ahead of the first visitor, put the focal point on faces, and export or import the settings.
  • Import and export the settings, on a tab of their own or with WP-CLI, to copy them to another site. The sign key and the cache never go along.
  • WooCommerce: a block theme's shop grid cropped on the focal point by itself, and a ratio for every photo on a product page.
  • Multisite: a Focalio screen in the Network Admin with every site's cache and warm-up, a template site whose settings new sites can start with (or that you copy to every site at once), and one licence for the network. warm and faces take --network.
  • Filters for themes: focalio_pro/preset_watermark leaves a preset out of the watermark, focalio_pro/woocommerce_crop leaves an image in a block theme's shop grid as WooCommerce made it.
Pro on the command lineterminal
$ wp focalio warm --images
$ wp focalio faces --dry-run
$ wp focalio warm --network
$ wp focalio settings export --file=focalio.json
wp focalio warm [--pages] [--images] [--network]
Render every image ahead of time: the ones on your pages (--pages), every preset and size (--images), or both.
wp focalio faces [--force] [--dry-run] [--network]
Put the focal point on the faces in every image. Images with a focal point, or already looked at, are skipped unless --force; --dry-run only reports.
wp focalio settings export [--file=<file>]
Write the settings as JSON to a file, or to the screen without --file.
wp focalio settings import <file> [--dry-run]
Read them from a file (or - for the input); --dry-run shows what would change.
Pro filtersfunctions.php
add_filter('focalio_pro/preset_watermark', function (?bool $choice, string $preset) {
    return $preset === 'avatar' ? false : $choice;
}, 10, 2);

add_filter('focalio_pro/woocommerce_crop', function (bool $crop, int $id) {
    return $id === 123 ? false : $crop;
}, 10, 2);

The full Pro docs come with the plugin.

Questions?

Ask in the support forum on WordPress.org, or send us a message.