{"id":165625,"date":"2022-11-18T09:13:04","date_gmt":"2022-11-18T09:13:04","guid":{"rendered":"https:\/\/wordpress.org\/plugins\/better-image-sizes\/"},"modified":"2025-12-01T23:18:05","modified_gmt":"2025-12-01T23:18:05","slug":"better-image-sizes","status":"publish","type":"plugin","link":"https:\/\/da.wordpress.org\/plugins\/better-image-sizes\/","author":9548563,"comment_status":"closed","ping_status":"closed","template":"","meta":{"_crdt_document":"","version":"3.9","stable_tag":"3.9","tested":"6.9.4","requires":"3.0.1","requires_php":"5.6","requires_plugins":null,"header_name":"Better image sizes","header_author":"KubiQ","header_description":"Better image sizes","assets_banners_color":"91c577","last_updated":"2025-12-01 23:18:05","external_support_url":"","external_repository_url":"","donate_link":"https:\/\/www.paypal.me\/jakubnovaksl","header_plugin_uri":"https:\/\/wp-speedup.eu","header_author_uri":"https:\/\/kubiq.sk","rating":5,"author_block_rating":0,"active_installs":2000,"downloads":22358,"num_ratings":4,"support_threads":0,"support_threads_resolved":0,"author_block_count":0,"sections":["description","installation","faq","changelog"],"tags":{"3.2":{"tag":"3.2","author":"kubiq","date":"2023-07-17 20:39:44"},"3.3":{"tag":"3.3","author":"kubiq","date":"2023-08-09 09:26:32"},"3.4":{"tag":"3.4","author":"kubiq","date":"2023-08-18 12:09:48"},"3.5":{"tag":"3.5","author":"kubiq","date":"2023-10-25 07:19:00"},"3.6":{"tag":"3.6","author":"kubiq","date":"2024-03-28 14:15:05"},"3.7":{"tag":"3.7","author":"kubiq","date":"2025-06-20 10:22:56"},"3.8":{"tag":"3.8","author":"kubiq","date":"2025-07-08 13:00:14"},"3.9":{"tag":"3.9","author":"kubiq","date":"2025-12-01 23:18:05"}},"upgrade_notice":[],"ratings":{"1":0,"2":0,"3":0,"4":0,"5":4},"assets_icons":{"icon-128x128.png":{"filename":"icon-128x128.png","revision":2820398,"resolution":"128x128","location":"assets","locale":""},"icon-256x256.png":{"filename":"icon-256x256.png","revision":2820398,"resolution":"256x256","location":"assets","locale":""}},"assets_banners":{"banner-1544x500.png":{"filename":"banner-1544x500.png","revision":2820398,"resolution":"1544x500","location":"assets","locale":""},"banner-772x250.png":{"filename":"banner-772x250.png","revision":2820398,"resolution":"772x250","location":"assets","locale":""}},"assets_blueprints":{},"all_blocks":[],"tagged_versions":["3.2","3.3","3.4","3.5","3.6","3.7","3.8","3.9"],"block_files":[],"assets_screenshots":{"screenshot-1.png":{"filename":"screenshot-1.png","revision":2820398,"resolution":"1","location":"assets","locale":""},"screenshot-2.png":{"filename":"screenshot-2.png","revision":2820398,"resolution":"2","location":"assets","locale":""},"screenshot-3.png":{"filename":"screenshot-3.png","revision":2820398,"resolution":"3","location":"assets","locale":""}},"screenshots":{"1":"Plugin settings","2":"Single file regenerate thumbnails","3":"Focal point picker"},"jetpack_post_was_ever_published":false},"plugin_section":[],"plugin_tags":[84,1452,606,6626,2956],"plugin_category":[50],"plugin_contributors":[81042],"plugin_business_model":[],"class_list":["post-165625","plugin","type-plugin","status-publish","hentry","plugin_tags-media","plugin_tags-optimize","plugin_tags-responsive","plugin_tags-retina","plugin_tags-thumbnails","plugin_category-media","plugin_contributors-kubiq","plugin_committers-kubiq"],"banners":{"banner":"https:\/\/ps.w.org\/better-image-sizes\/assets\/banner-772x250.png?rev=2820398","banner_2x":"https:\/\/ps.w.org\/better-image-sizes\/assets\/banner-1544x500.png?rev=2820398","banner_rtl":false,"banner_2x_rtl":false},"icons":{"svg":false,"icon":"https:\/\/ps.w.org\/better-image-sizes\/assets\/icon-128x128.png?rev=2820398","icon_2x":"https:\/\/ps.w.org\/better-image-sizes\/assets\/icon-256x256.png?rev=2820398","generated":false},"screenshots":[{"src":"https:\/\/ps.w.org\/better-image-sizes\/assets\/screenshot-1.png?rev=2820398","caption":"Plugin settings"},{"src":"https:\/\/ps.w.org\/better-image-sizes\/assets\/screenshot-2.png?rev=2820398","caption":"Single file regenerate thumbnails"},{"src":"https:\/\/ps.w.org\/better-image-sizes\/assets\/screenshot-3.png?rev=2820398","caption":"Focal point picker"}],"raw_content":"<!--section=description-->\n<p>This plugin is ment mostly for developers. You need to use its functions in your theme or plugin to make it works.<\/p>\n\n<p>This plugin offers functionality like <strong>face detection crop<\/strong>, <strong>focal point selector<\/strong> for every image, <strong>function to output responsive &lt;picture&gt; sizes<\/strong> and more.<\/p>\n\n<h3>Why to use this plugin?<\/h3>\n\n<p>WordPress will automatically create a lot of smaller images for every uploaded image.\nYou mostly need just 1 or 2 of them, so this is a waste of your server space and resources.\nAlso cropped images are generated from the center by default, which can be a problem many times.<\/p>\n\n<p><strong>This plugin allows you to:<\/strong><\/p>\n\n<ul>\n<li>disable autogenerated image sizes<\/li>\n<li>dynamically generate only needed image sizes for only needed images<\/li>\n<li>delete generated image sizes from this plugin individually or all together<\/li>\n<li>specify different focal point that will be in the focus while creating cropped versions of the image<\/li>\n<li>automatically detect focal point by face detection algorithm<\/li>\n<li>disable big image size threshold, so image bigger than 2560x2560px will be NOT scaled down<\/li>\n<\/ul>\n\n<h3>How it works<\/h3>\n\n<ol>\n<li>if you disable existing autogenerated image sizes, then newly uploaded images will not create its sizes<\/li>\n<li>you need to specify in your code what size is needed for the image<\/li>\n<li>image is dynamically created on the first visit of the page and is stored in <code>uploads<\/code> folder<\/li>\n<li>every next visit of that page will just load already generated image<\/li>\n<\/ol>\n\n<h3>Functions<\/h3>\n\n<p><strong>bis_get_attachment_image_src( $attachment_id, $size, $crop )<\/strong><\/p>\n\n<p>Function inspired by default <code>wp_get_attachment_image_src<\/code>.\nIf you used <em>Fly Dynamic Image Resizer<\/em> before, you don't need to replace <code>fly_get_attachment_image_src<\/code> functions in your code - there is a fallback, so you can deactivate <em>Fly Dynamic Image Resizer<\/em> and it will still work.<\/p>\n\n<p>Parameters:<\/p>\n\n<ul>\n<li><p><strong>attachment_id<\/strong> (integer)(required)\nThe ID of the image attachment\nExample: <code>123<\/code> or <code>get_post_thumbnail_id()<\/code> or <code>get_field('my_image')<\/code><\/p><\/li>\n<li><p><strong>size<\/strong> (array)(required)\nAn array with the width and height\nExample: <code>[ 1920, 1080 ]<\/code><\/p><\/li>\n<li><p><strong>crop<\/strong> (boolean\/integer\/array\/string)(optional)\nSkip this or pass <code>false<\/code> or <code>0<\/code> if you don't want to crop, just rescale,\notherwise pass <code>true<\/code> or <code>1<\/code> to use focal point crop that is selected in admin media (by default center),\nor pass array with string x-axis and y-axis parameters like <code>[ 'right', 'bottom' ]<\/code>\nor pass array with numeric x-axis and y-axis parameters like <code>[ 0.5, 0.8 ]<\/code>\nor pass string <code>'face'<\/code> to automatically detect face position (can be exhaustive on server resources)<\/p><\/li>\n<\/ul>\n\n<p>Returns:<\/p>\n\n<pre><code>array(\n    'src' =&gt; (string) url of the image,\n    'width' =&gt; (integer) width in pixels,\n    'height' =&gt; (integer) height in pixels\n)\n<\/code><\/pre>\n\n<p>&nbsp;<\/p>\n\n<p><strong>bis_get_attachment_image( $attachment_id, $size, $crop, $attr )<\/strong><\/p>\n\n<p>Function inspired by default <code>wp_get_attachment_image<\/code>.\nIf you used <em>Fly Dynamic Image Resizer<\/em> before, you don't need to replace <code>fly_get_attachment_image<\/code> functions in your code - there is a fallback, so you can deactivate <em>Fly Dynamic Image Resizer<\/em> and it will still work.<\/p>\n\n<p>Parameters:<\/p>\n\n<ul>\n<li><p><strong>attachment_id<\/strong> (integer)(required)\nThe ID of the image attachment\nExample: <code>123<\/code> or <code>get_post_thumbnail_id()<\/code> or <code>get_field('my_image')<\/code><\/p><\/li>\n<li><p><strong>size<\/strong> (array)(required)\nAn array with the width and height\nExample: <code>[ 1920, 1080 ]<\/code><\/p><\/li>\n<li><p><strong>crop<\/strong> (boolean\/integer\/array\/string)(optional)\nSkip this or pass <code>false<\/code> or <code>0<\/code> if you don't want to crop, just rescale,\notherwise pass <code>true<\/code> or <code>1<\/code> to use focal point crop that is selected in admin media (by default center),\nor pass array with string x-axis and y-axis parameters like <code>[ 'right', 'bottom' ]<\/code>\nor pass array with numeric x-axis and y-axis parameters like <code>[ 0.5, 0.8 ]<\/code>\nor pass string <code>'face'<\/code> to automatically detect face position (can be exhaustive on server resources)<\/p><\/li>\n<li><p><strong>attr<\/strong> (array)(optional)\nAn array of attributes\nSpecial attribute <code>retina<\/code> allows you to automatically generate srcset for <code>@2x<\/code> retina devices\nExample: <code>array( 'retina' =&gt; true, 'alt' =&gt; 'Custom alt text', 'class' =&gt; 'my-class', 'id' =&gt; 'my-id' )<\/code><\/p><\/li>\n<\/ul>\n\n<p>Returns:<\/p>\n\n<pre><code>&lt;img src=\"https:\/\/web.com\/wp-content\/uploads\/bis-images\/1234\/your-image-500x500-f50_50.jpg\" width=\"500\" height=\"500\" alt=\"Alt text\"&gt;\n<\/code><\/pre>\n\n<p>&nbsp;<\/p>\n\n<p><strong>bis_get_attachment_picture( $attachment_id, $sizes, $attr )<\/strong><\/p>\n\n<p>Parameters:<\/p>\n\n<ul>\n<li><p><strong>attachment_id<\/strong> (integer)(required)\nThe ID of the image attachment\nExample: <code>123<\/code> or <code>get_post_thumbnail_id()<\/code> or <code>get_field('my_image')<\/code><\/p><\/li>\n<li><p><strong>sizes<\/strong> (array)(required)\nAn array with the <code>key =&gt; value<\/code> pair\nwhere <code>key<\/code> means <strong>breakpoint<\/strong> \nand <code>value<\/code> is array of <strong>width, height, crop and alternative_attachment_id<\/strong>\nExample: <code>[ 767 =&gt; [ 767, 400, 1, 987 ], 9999 =&gt; [ 1200, 500, 1 ] ]<\/code>\nThis will generate <code>&lt;source media=\"(max-width:767px)\" srcset=\"image987_767x400.jpg\"&gt;<\/code>\nand <code>&lt;source media=\"(max-width:9999px)\" srcset=\"image_1200x500.jpg\"&gt;<\/code>\nand <code>&lt;source media=\"(min-width:10000px)\" srcset=\"image.jpg\"&gt;<\/code>\nIf you will provide also key <code>0<\/code> then it will replace <code>&lt;img&gt;<\/code>.<\/p><\/li>\n<li><p><strong>attr<\/strong> (array)(optional)\nAn array of attributes\nSpecial attribute <code>retina<\/code> allows you to automatically generate srcset for <code>@2x<\/code> retina devices\nExample: <code>array( 'retina' =&gt; true, 'alt' =&gt; 'Custom alt text', 'class' =&gt; 'my-class', 'id' =&gt; 'my-id' )<\/code><\/p><\/li>\n<\/ul>\n\n<p>Example:\nTo 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:<\/p>\n\n<pre><code>echo bis_get_attachment_picture(\n    get_post_thumbnail_id(),\n    [\n        375 =&gt; [ 375, 500, 1, 987 ],\n        575 =&gt; [ 575, 500, 1, 987 ],\n        767 =&gt; [ 767, 500, 1, 987 ],\n        991 =&gt; [ 991, 500, 1 ],\n        1199 =&gt; [ 1199, 500, 1 ],\n        1399 =&gt; [ 1399, 500, 1 ],\n        1600 =&gt; [ 1600, 500, 1 ],\n        1920 =&gt; [ 1920, 500, 1 ],\n        2560 =&gt; [ 2560, 500, 1 ],\n        3440 =&gt; [ 3440, 500, 1 ],\n        3840 =&gt; [ 3840, 500, 1 ],\n    ]\n);\n<\/code><\/pre>\n\n<p>Returns:<\/p>\n\n<pre><code>&lt;picture&gt;\n    &lt;source media=\"(max-width:375px)\" srcset=\"https:\/\/web.com\/wp-content\/uploads\/bis-images\/987\/your-image-375x500-f50_50.jpg\"&gt;\n    &lt;source media=\"(max-width:575px)\" srcset=\"https:\/\/web.com\/wp-content\/uploads\/bis-images\/987\/your-image-575x500-f50_50.jpg\"&gt;\n    &lt;source media=\"(max-width:767px)\" srcset=\"https:\/\/web.com\/wp-content\/uploads\/bis-images\/987\/your-image-767x500-f50_50.jpg\"&gt;\n    &lt;source media=\"(max-width:991px)\" srcset=\"https:\/\/web.com\/wp-content\/uploads\/bis-images\/123\/your-image-991x500-f50_50.jpg\"&gt;\n    &lt;source media=\"(max-width:1199px)\" srcset=\"https:\/\/web.com\/wp-content\/uploads\/bis-images\/123\/your-image-1199x500-f50_50.jpg\"&gt;\n    &lt;source media=\"(max-width:1399px)\" srcset=\"https:\/\/web.com\/wp-content\/uploads\/bis-images\/123\/your-image-1399x500-f50_50.jpg\"&gt;\n    &lt;source media=\"(max-width:1600px)\" srcset=\"https:\/\/web.com\/wp-content\/uploads\/bis-images\/123\/your-image-1600x500-f50_50.jpg\"&gt;\n    &lt;source media=\"(max-width:1920px)\" srcset=\"https:\/\/web.com\/wp-content\/uploads\/bis-images\/123\/your-image-1920x500-f50_50.jpg\"&gt;\n    &lt;source media=\"(max-width:2560px)\" srcset=\"https:\/\/web.com\/wp-content\/uploads\/bis-images\/123\/your-image-2560x500-f50_50.jpg\"&gt;\n    &lt;source media=\"(max-width:3440px)\" srcset=\"https:\/\/web.com\/wp-content\/uploads\/bis-images\/123\/your-image-3440x500-f50_50.jpg\"&gt;\n    &lt;source media=\"(max-width:3840px)\" srcset=\"https:\/\/web.com\/wp-content\/uploads\/bis-images\/123\/your-image-3840x500-f50_50.jpg\"&gt;\n    &lt;source media=\"(min-width:3841px)\" srcset=\"https:\/\/web.com\/wp-content\/uploads\/2022\/11\/your-image.jpg\"&gt;\n    &lt;img width=\"4000\" height=\"2000\" src=\"https:\/\/web.com\/wp-content\/uploads\/2022\/11\/your-image.jpg\" alt=\"Some alt\" loading=\"lazy\"&gt;\n&lt;\/picture&gt;\n<\/code><\/pre>\n\n<p>&nbsp;<\/p>\n\n<h3>There is no fallback for <code>fly_add_image_size<\/code> function<\/h3>\n\n<p>If you used <em>Fly Dynamic Image Resizer<\/em> before, you need to remove <code>fly_add_image_size<\/code> functions from your code.\nYou can create your own variables for sizes if you need it, like<\/p>\n\n<pre><code>define( 'MY_CUSTOM_SIZE', [ 1000, 200 ] );\n<\/code><\/pre>\n\n<p>and then just us it inside functions, like:<\/p>\n\n<pre><code>echo bis_get_attachment_image( get_post_thumbnail_id(), MY_CUSTOM_SIZE );\n<\/code><\/pre>\n\n<p>&nbsp;<\/p>\n\n<h3>Support other extensions than JPG, PNG and WEBP<\/h3>\n\n<p>This plugin works by default only with JPG, PNG and WEBP files,\nbut you can easily allow any other mime types,\njust use this code eg. in <code>wp-config.php<\/code> or in your <code>functions.php<\/code><\/p>\n\n<pre><code>define( 'BIS_ALLOWED_MIME_TYPES', array( 'image\/jpeg', 'image\/png', 'any_other\/mime_type' ) );\n<\/code><\/pre>\n\n<p>&nbsp;<\/p>\n\n<h3>Get selected image focal point<\/h3>\n\n<p>Focal point data are stored in the attachement post metas.\nThere is also custom sanitize function, that you can use.<\/p>\n\n<pre><code>$focal_point = sanitize_focal_point( get_post_meta( get_post_thumbnail_id(), 'focal_point', true ) );\n<\/code><\/pre>\n\n<p>Returns:<\/p>\n\n<pre><code>array( 0.5, 0.8 )\n<\/code><\/pre>\n\n<p>which means that focal point is 50% from left and 80% from top<\/p>\n\n<!--section=installation-->\n<ol>\n<li>Upload the plugin files to the \/wp-content\/plugins\/ directory, or install the plugin through the WordPress plugins screen directly.<\/li>\n<li>Activate the plugin through the \u2018Plugins\u2019 screen in WordPress<\/li>\n<\/ol>\n\n<!--section=faq-->\n<dl>\n<dt id='images%20stored%20location'><h3>Images stored location<\/h3><\/dt>\n<dd><p>\/wp-content\/uploads\/bis-images\/{IMAGE_ID}\/{IMAGE_FILENAME}-{IMAGE_SIZE}-f{IMAGE_FOCAL_POINT}.{IMAGE_EXTENSION}<\/p><\/dd>\n\n<\/dl>\n\n<!--section=changelog-->\n<h4>3.9<\/h4>\n\n<ul>\n<li>tested on WP 6.9<\/li>\n<li>new user role capability regenerate_images that allows users to regenerate images<\/li>\n<\/ul>\n\n<h4>3.8<\/h4>\n\n<ul>\n<li>bis_get_attachment_picture function using $sizes argument with key 0 will replace  tag in <\/li>\n<\/ul>\n\n<h4>3.7<\/h4>\n\n<ul>\n<li>tested on WP 6.8<\/li>\n<li>new option \"Disable upscaling\" that is checked by default - it will return the full original image if it's smaller than requested size<\/li>\n<\/ul>\n\n<h4>3.6<\/h4>\n\n<ul>\n<li>tested on WP 6.5<\/li>\n<\/ul>\n\n<h4>3.5<\/h4>\n\n<ul>\n<li>tested on WP 6.4<\/li>\n<\/ul>\n\n<h4>3.4<\/h4>\n\n<ul>\n<li>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<\/li>\n<\/ul>\n\n<h4>3.3<\/h4>\n\n<ul>\n<li>tested on WP 6.3<\/li>\n<li>removed deprecated lazy loading function<\/li>\n<\/ul>\n\n<h4>3.2<\/h4>\n\n<ul>\n<li>enable also for WebP mime type by default<\/li>\n<\/ul>\n\n<h4>3.1<\/h4>\n\n<ul>\n<li>enhanced face detection crop position<\/li>\n<li>fallback to old focal point if face not found<\/li>\n<\/ul>\n\n<h4>3.0<\/h4>\n\n<ul>\n<li>new Face Detection option for $crop (use 'face')<\/li>\n<\/ul>\n\n<h4>2.0<\/h4>\n\n<ul>\n<li>fix deleting single image sizes<\/li>\n<\/ul>\n\n<h4>1.9<\/h4>\n\n<ul>\n<li>make retina attribute works also with not-cropped images<\/li>\n<\/ul>\n\n<h4>1.8<\/h4>\n\n<ul>\n<li>add missing parameter for wp_get_attachment_image<\/li>\n<\/ul>\n\n<h4>1.7<\/h4>\n\n<ul>\n<li>fix for images with zero width - force crop to false in that case<\/li>\n<\/ul>\n\n<h4>1.6<\/h4>\n\n<ul>\n<li>fix missing PHP variable causing error on some servers<\/li>\n<\/ul>\n\n<h4>1.5<\/h4>\n\n<ul>\n<li>fix for images with zero height - force crop to false in that case<\/li>\n<\/ul>\n\n<h4>1.4<\/h4>\n\n<ul>\n<li>return empty array for _src function if image was deleted<\/li>\n<\/ul>\n\n<h4>1.3<\/h4>\n\n<ul>\n<li>make retina attribute works also in bis_get_attachment_picture function<\/li>\n<\/ul>\n\n<h4>1.2<\/h4>\n\n<ul>\n<li>return correct\/consistent array keys with bis_get_attachment_image_src even when wp_get_attachment_image_src is called<\/li>\n<\/ul>\n\n<h4>1.1<\/h4>\n\n<ul>\n<li>small fix for resizer when height is zero<\/li>\n<\/ul>\n\n<h4>1.0<\/h4>\n\n<ul>\n<li>First version<\/li>\n<\/ul>","raw_excerpt":"Dynamically generate only needed image sizes for only needed images, with manually selected focal point for crops","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/da.wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin\/165625","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/da.wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin"}],"about":[{"href":"https:\/\/da.wordpress.org\/plugins\/wp-json\/wp\/v2\/types\/plugin"}],"replies":[{"embeddable":true,"href":"https:\/\/da.wordpress.org\/plugins\/wp-json\/wp\/v2\/comments?post=165625"}],"author":[{"embeddable":true,"href":"https:\/\/da.wordpress.org\/plugins\/wp-json\/wporg\/v1\/users\/kubiq"}],"wp:attachment":[{"href":"https:\/\/da.wordpress.org\/plugins\/wp-json\/wp\/v2\/media?parent=165625"}],"wp:term":[{"taxonomy":"plugin_section","embeddable":true,"href":"https:\/\/da.wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin_section?post=165625"},{"taxonomy":"plugin_tags","embeddable":true,"href":"https:\/\/da.wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin_tags?post=165625"},{"taxonomy":"plugin_category","embeddable":true,"href":"https:\/\/da.wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin_category?post=165625"},{"taxonomy":"plugin_contributors","embeddable":true,"href":"https:\/\/da.wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin_contributors?post=165625"},{"taxonomy":"plugin_business_model","embeddable":true,"href":"https:\/\/da.wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin_business_model?post=165625"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}