Focal Point
Set the important part of a photograph once, and every crop of it keeps that part in view. Click the picture in the Media Library to place a focal point, and Bricks images and backgrounds use it wherever the image is cropped to a different shape. An element can override it, ignore it, or use a different point at tablet and mobile widths.
Version: 1.5.0 · Requires: PHP 7.4+ and Bricks. Gallery and slider support needs the WordPress HTML API, which any current WordPress has. · Live demo
Installation
- Upload and activate the plugin.
- Open any image in Media, Library. A Focal point field appears under the image details.
- Click the photograph to set the point, drag it, or use the arrow keys. Save as normal.
The Media Library field
- Click, drag or use the arrow keys to move the point, or type the percentages across and down.
- Centre clears the point.
- Three small previews (wide, square and portrait) show how the image will be cropped.
- The point is stored on the attachment as two percentages. It does nothing to the file itself, so you can change it at any time and every crop follows.
On Bricks elements
A Focal point group appears in the Style tab of the Image, Gallery, Carousel, Nested Slider, Section, Container, Block, Div and several other elements. Each has a behaviour:
| Behaviour | What happens |
|---|---|
| Use Media Library (default) | The attachment’s focal point is applied. Images with no point stay as Bricks would show them. |
| Override for this element | Type your own across and down percentages for this element only. The attachment is not changed. |
| Ignore focal point | The element is left exactly as Bricks renders it. |
It works on Image elements (object position) and on background images (background position), including Image Gallery, Carousel and Nested Slider images, each using its own point.
Different points at different widths
Tablet, mobile and mobile portrait each have their own choice: inherit the base position, override it at that width, or ignore the focal point at that width. The widths follow your Bricks breakpoints.
Which position wins
- A position you set yourself in the native Bricks controls (object position or background position).
- The element’s own focal point override.
- The attachment’s focal point from the Media Library.
- Bricks’ normal centred crop.
Editing from the front end
When you are logged in and allowed to upload files, an Edit image focal points link appears in the admin bar. Click it, then click an image on the page to open the same picker. It saves to the attachment, so it changes every place the image is used. Visitors never receive the editing scripts.
While editing is switched on, every identifiable image on the page shows a round dot at its current focal point. Images with no point yet show a dashed hollow ring at the centre, so you can see what still needs setting. The dots follow the images as you scroll or resize and update after you save. Click the link again to stop editing.
The image must be identifiable. That works for images with a WordPress image class or attachment attribute, and for same-site upload URLs. Background-only images with no attachment ID cannot be edited by clicking.
Dynamic and offloaded images
- Featured images, attachment IDs and ACF image fields that return an ID or an array are resolved automatically.
- A URL from this site’s uploads folder is matched to its attachment. Remote URLs are never guessed.
- For offloaded media or another provider, return the attachment ID from the
nlfp_resolve_attachment_idfilter. - Use
nlfp_responsive_breakpointsto change the widths used for the tablet and mobile choices. - Plain WordPress image output is left alone by default. Return true from
nlfp_enable_global_wordpress_imagesto apply focal points to every WordPress image.
Security
Reading or saving a focal point needs permission to edit that attachment and a valid nonce. Values are clamped to 0 to 100 and stored as plain text in the _nlfp_point field. No data leaves your site.
Known limits
- In the Bricks editor, a crosshair button sits beside Object position, Background position and the override fields. It opens the focal point dialog for the selected element. Drag the reticle (or use the arrow keys), then Apply to write the value to that field, or Save to Media Library to store it on the attachment.
- Changes appear on the next Bricks render rather than live on the canvas.
- Slides built with a CSS background, images from a remote URL and third-party elements are only covered where the image can be resolved to an attachment.
- Check the result at each of your breakpoints. Position rules written by other plugins or by your own CSS can take precedence.
Related plugins
Focal point suits the galleries too: see Enhanced Galleries and Adaptive Bricks Gallery.