Skip to content

coxmi/image-focal-point

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Image focal point

WordPress plugin to select a focal point for images in your media library


Screenshot

Installation

Upload the plugin folder to the plugins directory, and activate on the plugins page.

Usage

In your theme, get the focal point position by calling get_post_meta with your attachment’s $id:

<?php
  $x = get_post_meta($attachmentId, "x", true);
  $y = get_post_meta($attachmentId, "y", true);
?>

The values returned are percentages from the left and top edges of the image, so you can use them in object-position or background-position:

<?php
  $focalpoint = "${x}% ${y}%";
  …
?>

<img style="object-position:<?php echo $focalpoint ?>">

About

WordPress focal point selection for images

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published