Add An Image Focus Point Tool To The WordPress Media Library

Add An Image Focus Point Tool To The WordPress Media Library

Element.How also offers premium tutorials! Check them here:

Table of Contents

In this tutorial you are going to learn how to add an Image Focus Point tool to the WordPress media library.

What's an Image Focus Point tool?

It allows you to quickly determine the x and y position of your preferred focus area for any image, very quickly, just by clicking on the image.

Add An Image Focus Point Tool To The WordPress Media Library 1

This x and y position can then be used in either the background-position or the object-position CSS properties, so that on any screen size, the important part of the image will be in view.

I had the idea for this after watching the WPTuts video of an image focus tool coming soon to Advanced Themer.

To be clear, the integration in Advanced Themer is better and more automatized, so if you are using Bricks Builder, definitely use that if you have it.

The advantage of the current method is that it adds the tool directly to the media library, so it works for 100% of WordPress websites.

The disadvantage is that you still have to set the CSS, or the styles by yourself in your favorite page builder or block editor addon.

Why would you want to use this image focus tool

Often the images we set on desktop end up cropping out someone or something important when viewed on other viewports.

By setting the focus point, you avoid this issue, and you always have the important part of the image in view.

The implementation

All you need to do to add the image focus tool to your Wordpress media library is to add the code below in a PHP code snippet, or in your child theme functions.php file.

Snippet name:
Add Image Focus Point Tool To The Media Library

Now activate your code snippet.

Here is what it looks like in the Code Snippets plugin:

Add An Image Focus Point Tool To The WordPress Media Library 2

How to use it

Now, go to your media library, open any image, and on the right you will see this:

Add An Image Focus Point Tool To The WordPress Media Library 3

Click any part of the image, and it will update with the xx% yy% values:

Add An Image Focus Point Tool To The WordPress Media Library 4

This isn't saved anywhere in the database, to avoid extra useless clutter. It's only a single click away, and for different use cases, you might want different focus point on the same image anyway.

Now simply use these values when setting your background images that are set to background-size: cover. Set the background-position: 26% 39%; , or the background-position-x: 26%; background-position-y: 39%;

Same for your images that are set to object-fit: cover. Set the object-position: 26% 39%;

Using it in Elementor

Elementor has options through the UI for the background-position, and object-position. However it's either very buggy, or missing a few options, so to properly set the focus point you pretty much have to use custom CSS.

For background images

To set the focus point on Elementor background image, set it to background size: cover in the Elementor UI, and then under Advanced > Custom CSS, set this CSS:

<script> 
/* Please login to get the code 
 * The code will be for the Add An Image Focus Point Tool To The WordPress Media Library tutorial 
 * Found at this URL https://element.how/add-image-focus-point-tool-to-wordpress-media-library/ 
 */ 
</script>

Of course replace the 26% 39% with your own focus point value.

For object-fit: cover images

For images that you set to object-fit:cover, you will need this CSS:

<script> 
/* Please login to get the code 
 * The code will be for the Add An Image Focus Point Tool To The WordPress Media Library tutorial 
 * Found at this URL https://element.how/add-image-focus-point-tool-to-wordpress-media-library/ 
 */ 
</script>

Elementor free users: see the Elementor Free Custom CSS tutorial.

Editor support

It works directly when choosing an image in the block editor, in the Elementor editor and in the Bricks Builder editor.

In the editor, you would click the small preview image in the top right:

Add An Image Focus Point Tool To The WordPress Media Library 5

It works on all WordPress websites by visiting the Media Library directly.

Conclusion

I hope you enjoy this Image Focus tool for the WordPress media libray!

Cheers!

Element.how also provides premium tutorials showing awesome advanced designs, check them out here.

Looking for something else? Search across 2927 Elements right here:

Checkout the Elementor Addon Finder directly

Leave a Reply