php 删除WordPress全尺寸图像插入post +选项并添加最大尺寸以防止用户插入大量i

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了php 删除WordPress全尺寸图像插入post +选项并添加最大尺寸以防止用户插入大量i相关的知识,希望对你有一定的参考价值。

<?php

/**
 * 
 * This removes the ability to add the FULL image size into a post, it does not alter or delete the image
 * Add whataever extra image sizes to the insert dropdown in WordPress you create via add_image_size
 * 
 *  For now we have to do it this way to make the labels translatable, see trac ref below.
 *
 *  If your theme has $content_width GLOBAL make sure and remove it
*/

//example to add post-size instead of using $content_width and a max-size
add_image_size( 'post-size', 600, 9999);
add_image_size( 'max-size', 1600, 900, true);

// over-ride image_size_names_choose
function add_image_insert_override($size_names){
 
  global $_wp_additional_image_sizes;
 
       //default array with hardcoded values for add_image_size
        $size_names = array(
                          'thumbnail' => __('Thumbnail'), 
                          'medium'    => __('Medium'), 
                          'large'     => __('Large'),
                          'post-size' => __('Post Size'),
                          'max-size'  => __('Max Size')
                          //'full'      => __('Full Size') bye bye
                        );
 
      return $size_names;
 
};
 
add_filter('image_size_names_choose', 'add_image_insert_override' );


// For referance
//http://core.trac.wordpress.org/ticket/20663, http://core.trac.wordpress.org/ticket/19990

?>

以上是关于php 删除WordPress全尺寸图像插入post +选项并添加最大尺寸以防止用户插入大量i的主要内容,如果未能解决你的问题,请参考以下文章

从图像源中删除最后一个字符

PHP 在Wordpress中强制实施最小图像尺寸

php 根据当前注册的图像尺寸(Wordpress),根据最小高度自动限制最小上传尺寸

php 过滤WordPress的图像插入

php 阻止Wordpress将额外的10px宽度插入图像标题短代码。

php 对Wordpress中的插入图像+标题进行了大修,以产生html5输出