WordPress plugin intelligence profile

Better image sizes

Dynamically generate only needed image sizes for only needed images, with manually selected focal point for crops

WP PlugIndex snapshot

Current directory snapshot

Tested up to WordPress 7.1
Current version4.0.1
WordPress coverageTested up to WordPress 7.1
Minimum stackWP 3.0.1 · PHP 5.6
Directory statusactive
Last directory update5 Oct 202627d ago
Active installations2K+Adoption metric — not a quality score
WordPress.org rating5.0 / 5 from 5 ratings
Official packageDirect from WordPress.org

Repository metrics are context, not quality scores. Active installations measure adoption and can strongly reflect a plugin’s age and historical popularity. Ratings, recent updates and “Tested up to” metadata also do not guarantee modern code, error-free operation, security, feature completeness or suitability for a particular site. Why active installs don’t tell the whole story →

WP PlugIndex currently records Better image sizes version 4.0.1 as active, updated 27d ago and tested up to WordPress 7.1.

Overview

About this plugin

This plugin is ment mostly for developers. You need to use its functions in your theme or plugin to make it works.

This plugin offers functionality like face detection crop, focal point selector for every image, function to output responsive <picture> sizes and more.

Why to use this plugin?

WordPress will automatically create a lot of smaller images for every uploaded image.

You mostly need just 1 or 2 of them, so this is a waste of your server space and resources.

Also cropped images are generated from the center by default, which can be a problem many times.

This plugin allows you to:

  • disable autogenerated image sizes
  • dynamically generate only needed image sizes for only needed images
  • delete generated image sizes from this plugin individually or all together
  • specify different focal point that will be in the focus while creating cropped versions of the image
  • automatically detect focal point by face detection algorithm
  • disable big image size threshold, so image bigger than 2560x2560px will be NOT scaled down

How it works

  • if you disable existing autogenerated image sizes, then newly uploaded images will not create its sizes
  • you need to specify in your code what size is needed for the image
  • image is dynamically created on the first visit of the page and is stored in uploads folder
  • every next visit of that page will just load already generated image

Functions

bis_get_attachment_image_src( $attachment_id, $size, $crop )

Function inspired by default wp_get_attachment_image_src.

If you used Fly Dynamic Image Resizer before, you don’t need to replace fly_get_attachment_image_src functions in your code – there is a fallback, so you can deactivate Fly Dynamic Image Resizer and it will still work.

Parameters:

-

attachment_id (integer)(required)

The ID of the image attachment

Example: 123 or get_post_thumbnail_id() or get_field('my_image')

-

size (array)(required)

An array with the width and height

Example: [ 1920, 1080 ]

-

crop (boolean/integer/array/string)(optional)

Skip this or pass false or 0 if you don’t want to crop, just rescale,

otherwise pass true or 1 to use focal point crop that is selected in admin media (by default center),

or pass array with string x-axis and y-axis parameters like [ 'right', 'bottom' ]

8 ]

or pass string 'face' to automatically detect face position (can be exhaustive on server resources)

Returns:

array( 'src' => (string) url of the image, 'width' => (integer) width in pixels, 'height' => (integer) height in pixels )

bis_get_attachment_image( $attachment_id, $size, $crop, $attr )

Function inspired by default wp_get_attachment_image.

If you used Fly Dynamic Image Resizer before, you don’t need to replace fly_get_attachment_image functions in your code – there is a fallback, so you can deactivate Fly Dynamic Image Resizer and it will still work.

Parameters:

-

attachment_id (integer)(required)

The ID of the image attachment

Example: 123 or get_post_thumbnail_id() or get_field('my_image')

-

size (array)(required)

An array with the width and height

Example: [ 1920, 1080 ]

-

crop (boolean/integer/array/string)(optional)

Skip this or pass false or 0 if you don’t want to crop, just rescale,

otherwise pass true or 1 to use focal point crop that is selected in admin media (by default center),

or pass array with string x-axis and y-axis parameters like [ 'right', 'bottom' ]

8 ]

or pass string 'face' to automatically detect face position (can be exhaustive on server resources)

-

attr (array)(optional)

An array of attributes

Special attribute retina allows you to automatically generate srcset for @2x retina devices

Example: array( 'retina' => true, 'alt' => 'Custom alt text', 'class' => 'my-class', 'id' => 'my-id' )

Returns:

jpg" width="500" height="500" alt="Alt text">

bis_get_attachment_picture( $attachment_id, $sizes, $attr )

Parameters:

-

attachment_id (integer)(required)

The ID of the image attachment

Example: 123 or get_post_thumbnail_id() or get_field('my_image')

-

sizes (array)(required)

An array with the key => value pair

where key means breakpoint

and value is array of width, height, crop and alternative_attachment_id

Example: [ 767 => [ 767, 400, 1, 987 ], 9999 => [ 1200, 500, 1 ] ]

jpg">

jpg">

jpg">

If you will provide also key 0 then it will replace <img>.

-

attr (array)(optional)

An array of attributes

Special attribute retina allows you to automatically generate srcset for @2x retina devices

Example: array( 'retina' => true, 'alt' => 'Custom alt text', 'class' => 'my-class', 'id' => 'my-id' )

Example:

To generate perfect fullwidth hero image, that will looks great on 4K devices and also on small phones, but it will load only needed size, you can use:

echo bis_get_attachment_picture( get_post_thumbnail_id(), [ 375 => [ 375, 500, 1, 987 ], 575 => [ 575, 500, 1, 987 ], 767 => [ 767, 500, 1, 987 ], 991 => [ 991, 500, 1 ], 1199 => [ 1199, 500, 1 ], 1399 => [ 1399, 500, 1 ], 1600 => [ 1600, 500, 1 ], 1920 => [ 1920, 500, 1 ], 2560 => [ 2560, 500, 1 ], 3440 => [ 3440, 500, 1 ], 3840 => [ 3840, 500, 1 ], ] );

Returns:

jpg" alt="Some alt" loading="lazy"> </picture>

There is no fallback for fly_add_image_size function

If you used Fly Dynamic Image Resizer before, you need to remove fly_add_image_size functions from your code.

You can create your own variables for sizes if you need it, like

define( 'MY_CUSTOM_SIZE', [ 1000, 200 ] );

and then just us it inside functions, like:

echo bis_get_attachment_image( get_post_thumbnail_id(), MY_CUSTOM_SIZE );

Support other extensions than JPG, PNG and WEBP

This plugin works by default only with JPG, PNG and WEBP files,

but you can easily allow any other mime types,

just use this code eg. php

define( 'BIS_ALLOWED_MIME_TYPES', array( 'image/jpeg', 'image/png', 'any_other/mime_type' ) );

Get selected image focal point

Focal point data are stored in the attachement post metas.

There is also custom sanitize function, that you can use.

$focal_point = sanitize_focal_point( get_post_meta( get_post_thumbnail_id(), 'focal_point', true ) );

Returns:

8 )

which means that focal point is 50% from left and 80% from top

WordPress.org metadata

Plugin tags

Topics listed for this plugin in the WordPress.org directory.

  • media
  • optimize
  • responsive
  • retina
  • thumbnails
Compatibility & maintenance

Compatibility & maintenance

Tested with WP 7.1

Marked as tested with the current WordPress 7.1 release.

Current WordPress releaseWordPress 7.1
WordPress.org Tested up to7.1
Minimum requirementsWordPress 3.0.1 · PHP 5.6
Update activity5 Oct 202627d ago

“Tested up to” is directory metadata supplied by the plugin author. WP PlugIndex does not turn an older declaration into a claim that the plugin is incompatible.

Changes recorded by WP PlugIndex

Recent tracked changes

Version4.04.0.1
Version3.94.0
WordPress compatibility6.9.77.1.2
Tracking & source

WP PlugIndex tracks public WordPress.org directory metadata and records selected version, compatibility and availability changes as they are detected.

Plugin watchlist

Watch this plugin

Sign in to your WP PlugIndex account or create a free account. Free accounts can watch up to 5 plugins and see what changed.

Watch limit

Watchlist limit reached

You have reached your current active watch limit.