在Wordpress中强制最小图像尺寸
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了在Wordpress中强制最小图像尺寸相关的知识,希望对你有一定的参考价值。
Add this snippet to your Wordpress theme's functions.php file to reject any image uploads that are below the specified dimensions.
/** * Enforce minimum image upload size. */ add_filter('wp_handle_upload_prefilter','handle_upload_prefilter'); function handle_upload_prefilter($file) { $width= $img[0]; $height =$img[1]; if ($width < $minimum['width'] ){ return array("error"=>"Image dimensions are too small. Minimum width is {$minimum['width']}px. Uploaded image width is $width px."); } elseif ($height < $minimum['height']){ return array("error"=>"Image dimensions are too small. Minimum height is {$minimum['height']}px. Uploaded image width is $width px."); } else { return $file; } }
以上是关于在Wordpress中强制最小图像尺寸的主要内容,如果未能解决你的问题,请参考以下文章
php 根据当前注册的图像尺寸(Wordpress),根据最小高度自动限制最小上传尺寸
php [自定义图像尺寸]添加自定义尺寸图像(上传媒体时的新尺寸)#wordpress #php