Created
July 4, 2021 15:03
-
-
Save hyperframed/9aaa4e953ace077ede8071344a6e6575 to your computer and use it in GitHub Desktop.
Wordpress Minimum Image Dimension for Uploads
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
add_filter('wp_handle_upload_prefilter','tc_handle_upload_prefilter'); | |
function tc_handle_upload_prefilter($file) | |
{ | |
$img=getimagesize($file['tmp_name']); | |
$minimum = array('width' => '400', 'height' => '400'); | |
$width= $img[0]; | |
$height =$img[1]; | |
if ($width < $minimum['width'] ) | |
return array("error"=>"Bildgröße zu klein. Das Minimum sind {$minimum['width']}px. Das hochgeladene Foto ist nur $width px breit."); | |
elseif ($height < $minimum['height']) | |
return array("error"=>"Bildgröße zu klein. Das Minimum sind {$minimum['height']}px. Das hochgeladene Foto ist nur $height px hoch."); | |
else | |
return $file; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment