How to Disable the Attachment Page in ...
WordPress Is Creating Attachment Pages You Don’t Need, you can Stop That with Code
...

WPCodeBox
596
Preserve MyListing website performance and disk storage by limiting image upload size. This code snippet helps govern image sizes, preventing massive uploads and ensuring optimal site health. Implement this essential snippet before launching your MyListing website to restrict image file uploads to a maximum of 600KB.
<?php
/**
* Author: MyListing Club
* Author URI: https://mylisting.club
*/
function max_image_size( $file ) {
$size = $file['size'];
$size = $size / 1024;
$type = $file['type'];
$is_image = strpos( $type, 'image' ) !== false;
$limit = 600;
$limit_output = '600KB';
if ( $is_image && $size > $limit ) {
$file['error'] = 'Image files must be smaller than ' . $limit_output;
}//end if
return $file;
}//end max_image_size()
add_filter( 'wp_handle_upload_prefilter', 'max_image_size' );





