{"id":45715,"date":"2022-07-08T14:30:14","date_gmt":"2022-07-08T14:30:14","guid":{"rendered":"https:\/\/code.dplugins.com\/?p=45715"},"modified":"2022-07-08T14:30:16","modified_gmt":"2022-07-08T14:30:16","slug":"disable-wordpress-default-image-sizes","status":"publish","type":"post","link":"https:\/\/code.dplugins.com\/disable-wordpress-default-image-sizes\/","title":{"rendered":"Disable WordPress default Image Sizes"},"content":{"rendered":"\n<p>I usually use images on my most of clients the maximum size of 1400px, and never used the medium_large image size for my clients except when the client forces to use. Then when I give the access to client, he may be sometime upload very large image which we don&#8217;t needed, so I use the below snippet to disable un-needed image sizes which wordpress generates for each uploaded file. Put this in any code-snippet plugin or functions.php file.<\/p>\n\n\n\n<p>I use Scripts organizer with the below settings :<\/p>\n\n\n\n<ol class=\"wp-block-list\"><li>Add a code block<\/li><li>Set Trigger Location to Everywhere<\/li><li>Put the code<\/li><li>Publish and you are done.<\/li><\/ol>\n\n\n\n<p>Note: If you have already have some images uploaded, then these image sizes are not deleted automatically.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"php\" class=\"language-php\">&lt;?php\n\/\/ Remove WP 'medium_large' SIZE\nadd_filter( 'intermediate_image_sizes', function( $sizes )\n{\n\treturn array_filter( $sizes, function( $val ) {\n\t\treturn 'medium_large' !== $val;\n\t});\n});\n\n\/\/ Remove 2x-medium-large and 2x-large SIZES\nadd_filter( 'intermediate_image_sizes', 'remove_default_img_sizes', 10, 1);\nfunction remove_default_img_sizes( $sizes ) {\n\t$targets = ['1536x1536', '2048x2048'];\n\tforeach($sizes as $size_index=&gt;$size) {\n\t\tif(in_array($size, $targets)) {\n\t\t\tunset($sizes[$size_index]);\n\t\t}\n\t}\n\treturn $sizes;\n}\n?&gt;<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>I usually use images on my most of clients the maximum size of 1400px, and never used the medium_large image size for my clients except when the client forces to use. Then when I give the access to client, he may be sometime upload very large image which we don&#8217;t needed, so I use the [&hellip;]<\/p>\n","protected":false},"author":5,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"slim_seo":{"title":"Disable WordPress default Image Sizes - Code DPlugins","description":"I usually use images on my most of clients the maximum size of 1400px, and never used the medium_large image size for my clients except when the client forces t"},"footnotes":""},"categories":[3],"tags":[59],"class_list":["post-45715","post","type-post","status-publish","format-standard","hentry","category-wordpress","tag-image"],"_links":{"self":[{"href":"https:\/\/code.dplugins.com\/wp-json\/wp\/v2\/posts\/45715","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/code.dplugins.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/code.dplugins.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/code.dplugins.com\/wp-json\/wp\/v2\/users\/5"}],"replies":[{"embeddable":true,"href":"https:\/\/code.dplugins.com\/wp-json\/wp\/v2\/comments?post=45715"}],"version-history":[{"count":1,"href":"https:\/\/code.dplugins.com\/wp-json\/wp\/v2\/posts\/45715\/revisions"}],"predecessor-version":[{"id":45716,"href":"https:\/\/code.dplugins.com\/wp-json\/wp\/v2\/posts\/45715\/revisions\/45716"}],"wp:attachment":[{"href":"https:\/\/code.dplugins.com\/wp-json\/wp\/v2\/media?parent=45715"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/code.dplugins.com\/wp-json\/wp\/v2\/categories?post=45715"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/code.dplugins.com\/wp-json\/wp\/v2\/tags?post=45715"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}