Title: Better image sizes
Author: kubiq
Published: <strong>November 18, 2022</strong>
Last modified: December 1, 2025

---

Search plugins

![](https://ps.w.org/better-image-sizes/assets/banner-772x250.png?rev=2820398)

![](https://ps.w.org/better-image-sizes/assets/icon-256x256.png?rev=2820398)

# Better image sizes

 By [kubiq](https://profiles.wordpress.org/kubiq/)

[Download](https://downloads.wordpress.org/plugin/better-image-sizes.3.9.zip)

 * [Details](https://wordpress.org/plugins/better-image-sizes/#description)
 * [Reviews](https://wordpress.org/plugins/better-image-sizes/#reviews)
 *  [Installation](https://wordpress.org/plugins/better-image-sizes/#installation)
 * [Development](https://wordpress.org/plugins/better-image-sizes/#developers)

 [Support](https://wordpress.org/support/plugin/better-image-sizes/)

## Description

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

 1. if you disable existing autogenerated image sizes, then newly uploaded images will
    not create its sizes
 2. you need to specify in your code what size is needed for the image
 3. image is dynamically created on the first visit of the page and is stored in `uploads`
    folder
 4. 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']`
   or pass array with numeric x-axis and y-axis parameters like `[ 0.5, 0.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']`
   or pass array with numeric x-axis and y-axis parameters like `[ 0.5, 0.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:

    ```
    <img src="https://web.com/wp-content/uploads/bis-images/1234/your-image-500x500-f50_50.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 ] ]` This will
   generate `<source media="(max-width:767px)" srcset="image987_767x400.jpg">` and`
   <source media="(max-width:9999px)" srcset="image_1200x500.jpg">` and `<source
   media="(min-width:10000px)" srcset="image.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:

    ```
    <picture>
        <source media="(max-width:375px)" srcset="https://web.com/wp-content/uploads/bis-images/987/your-image-375x500-f50_50.jpg">
        <source media="(max-width:575px)" srcset="https://web.com/wp-content/uploads/bis-images/987/your-image-575x500-f50_50.jpg">
        <source media="(max-width:767px)" srcset="https://web.com/wp-content/uploads/bis-images/987/your-image-767x500-f50_50.jpg">
        <source media="(max-width:991px)" srcset="https://web.com/wp-content/uploads/bis-images/123/your-image-991x500-f50_50.jpg">
        <source media="(max-width:1199px)" srcset="https://web.com/wp-content/uploads/bis-images/123/your-image-1199x500-f50_50.jpg">
        <source media="(max-width:1399px)" srcset="https://web.com/wp-content/uploads/bis-images/123/your-image-1399x500-f50_50.jpg">
        <source media="(max-width:1600px)" srcset="https://web.com/wp-content/uploads/bis-images/123/your-image-1600x500-f50_50.jpg">
        <source media="(max-width:1920px)" srcset="https://web.com/wp-content/uploads/bis-images/123/your-image-1920x500-f50_50.jpg">
        <source media="(max-width:2560px)" srcset="https://web.com/wp-content/uploads/bis-images/123/your-image-2560x500-f50_50.jpg">
        <source media="(max-width:3440px)" srcset="https://web.com/wp-content/uploads/bis-images/123/your-image-3440x500-f50_50.jpg">
        <source media="(max-width:3840px)" srcset="https://web.com/wp-content/uploads/bis-images/123/your-image-3840x500-f50_50.jpg">
        <source media="(min-width:3841px)" srcset="https://web.com/wp-content/uploads/2022/11/your-image.jpg">
        <img width="4000" height="2000" src="https://web.com/wp-content/uploads/2022/11/your-image.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. in `wp-config.php` or in your`
functions.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:

    ```
    array( 0.5, 0.8 )
    ```

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

## Screenshots

 * [[
 * Plugin settings
 * [[
 * Single file regenerate thumbnails
 * [[
 * Focal point picker

## Installation

 1. Upload the plugin files to the /wp-content/plugins/ directory, or install the plugin
    through the WordPress plugins screen directly.
 2. Activate the plugin through the ‘Plugins’ screen in WordPress

## FAQ

### Images stored location

/wp-content/uploads/bis-images/{IMAGE_ID}/{IMAGE_FILENAME}-{IMAGE_SIZE}-f{IMAGE_FOCAL_POINT}.{
IMAGE_EXTENSION}

## Reviews

![](https://secure.gravatar.com/avatar/7bad8cde302384b7eea2c43b6a55103c1ba042028fc1a55bf6447ada2d630121?
s=60&d=retro&r=g)

### 󠀁[Fantastic](https://wordpress.org/support/topic/fantastic-3485/)󠁿

 [Code Muffin](https://profiles.wordpress.org/code-muffin/) January 21, 2026

Great plugin. It lets you cut out all the random image sizes (and their file bloat)
so you can just make the image sizes you actually need. One of the first plugins
I install for every build. I’m so thankful to the developer for carrying on the 
legacy of the deprecated “Fly Images” plugin.

![](https://secure.gravatar.com/avatar/6631b1c99bfde142fdc0585e740db2c026d8dd88c75b93cfa038df29a269133c?
s=60&d=retro&r=g)

### 󠀁[Excellent](https://wordpress.org/support/topic/excellent-14080/)󠁿

 [tedmw](https://profiles.wordpress.org/tedmw/) October 1, 2025

This is a great successor to Fly Dynamic Image Resizer, which is no longer maintained.
The focal-point picker is a feature I wish WP would add to core (see github.com/
WordPress/gutenberg/issues/20321). Thanks for all your hard work on this plugin!

![](https://secure.gravatar.com/avatar/296b8de46c55cf788b0fb3db38f49b222b8e36ef2bcac3a1355b45b749d6ff31?
s=60&d=retro&r=g)

### 󠀁[Superb!](https://wordpress.org/support/topic/superb-1052/)󠁿

 [snoop23](https://profiles.wordpress.org/snoop23/) June 20, 2025

Really love this plugin. Thanks for keeping it updated.

![](https://secure.gravatar.com/avatar/2f86d42ce1d6742181f30ddd54d2fa0a25ea25da27baeaae2875170e246037a0?
s=60&d=retro&r=g)

### 󠀁[Top plugin !](https://wordpress.org/support/topic/top-plugin-403/)󠁿

 [nauar](https://profiles.wordpress.org/nauar/) February 23, 2023

Simple and very usefull ! Great work!

![](https://secure.gravatar.com/avatar/4bf0aec477628bf7c54f20166fc4160d2f17ff7fd84fb2b3e4915a87858e4c56?
s=60&d=retro&r=g)

### 󠀁[Great plugin!](https://wordpress.org/support/topic/great-plugin-35786/)󠁿

 [arvoisa](https://profiles.wordpress.org/arvoisa/) December 20, 2022

Best in category.

 [ Read all 4 reviews ](https://wordpress.org/support/plugin/better-image-sizes/reviews/)

## Contributors & Developers

“Better image sizes” is open source software. The following people have contributed
to this plugin.

Contributors

 *   [ kubiq ](https://profiles.wordpress.org/kubiq/)

[Translate “Better image sizes” into your language.](https://translate.wordpress.org/projects/wp-plugins/better-image-sizes)

### Interested in development?

[Browse the code](https://plugins.trac.wordpress.org/browser/better-image-sizes/),
check out the [SVN repository](https://plugins.svn.wordpress.org/better-image-sizes/),
or subscribe to the [development log](https://plugins.trac.wordpress.org/log/better-image-sizes/)
by [RSS](https://plugins.trac.wordpress.org/log/better-image-sizes/?limit=100&mode=stop_on_copy&format=rss).

## Changelog

#### 3.9

 * tested on WP 6.9
 * new user role capability regenerate_images that allows users to regenerate images

#### 3.8

 * bis_get_attachment_picture function using $sizes argument with key 0 will replace
   tag in

#### 3.7

 * tested on WP 6.8
 * new option “Disable upscaling” that is checked by default – it will return the
   full original image if it’s smaller than requested size

#### 3.6

 * tested on WP 6.5

#### 3.5

 * tested on WP 6.4

#### 3.4

 * new (4th) parameter for bis_get_attachment_picture $sizes – you can specify alternative
   image ID, so you can easily use different image eg. on mobile and desktop

#### 3.3

 * tested on WP 6.3
 * removed deprecated lazy loading function

#### 3.2

 * enable also for WebP mime type by default

#### 3.1

 * enhanced face detection crop position
 * fallback to old focal point if face not found

#### 3.0

 * new Face Detection option for $crop (use ‘face’)

#### 2.0

 * fix deleting single image sizes

#### 1.9

 * make retina attribute works also with not-cropped images

#### 1.8

 * add missing parameter for wp_get_attachment_image

#### 1.7

 * fix for images with zero width – force crop to false in that case

#### 1.6

 * fix missing PHP variable causing error on some servers

#### 1.5

 * fix for images with zero height – force crop to false in that case

#### 1.4

 * return empty array for _src function if image was deleted

#### 1.3

 * make retina attribute works also in bis_get_attachment_picture function

#### 1.2

 * return correct/consistent array keys with bis_get_attachment_image_src even when
   wp_get_attachment_image_src is called

#### 1.1

 * small fix for resizer when height is zero

#### 1.0

 * First version

## Meta

 *  Version **3.9**
 *  Last updated **4 months ago**
 *  Active installations **2,000+**
 *  WordPress version ** 3.0.1 or higher **
 *  Tested up to **6.9.4**
 *  PHP version ** 5.6 or higher **
 * Tags
 * [media](https://wordpress.org/plugins/tags/media/)[Optimize](https://wordpress.org/plugins/tags/optimize/)
   [responsive](https://wordpress.org/plugins/tags/responsive/)[retina](https://wordpress.org/plugins/tags/retina/)
   [thumbnails](https://wordpress.org/plugins/tags/thumbnails/)
 *  [Advanced View](https://wordpress.org/plugins/better-image-sizes/advanced/)

## Ratings

 5 out of 5 stars.

 *  [  5 5-star reviews     ](https://wordpress.org/support/plugin/better-image-sizes/reviews/?filter=5)
 *  [  0 4-star reviews     ](https://wordpress.org/support/plugin/better-image-sizes/reviews/?filter=4)
 *  [  0 3-star reviews     ](https://wordpress.org/support/plugin/better-image-sizes/reviews/?filter=3)
 *  [  0 2-star reviews     ](https://wordpress.org/support/plugin/better-image-sizes/reviews/?filter=2)
 *  [  0 1-star reviews     ](https://wordpress.org/support/plugin/better-image-sizes/reviews/?filter=1)

[Your review](https://wordpress.org/support/plugin/better-image-sizes/reviews/#new-post)

[See all reviews](https://wordpress.org/support/plugin/better-image-sizes/reviews/)

## Contributors

 *   [ kubiq ](https://profiles.wordpress.org/kubiq/)

## Support

Got something to say? Need help?

 [View support forum](https://wordpress.org/support/plugin/better-image-sizes/)

## Donate

Would you like to support the advancement of this plugin?

 [ Donate to this plugin ](https://www.paypal.me/jakubnovaksl)