Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/239.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php Wordpress-上传图像并获取全尺寸缩略图_Php_Wordpress - Fatal编程技术网

Php Wordpress-上传图像并获取全尺寸缩略图

Php Wordpress-上传图像并获取全尺寸缩略图,php,wordpress,Php,Wordpress,当你上传图片时,wordpress会制作150x150、全尺寸的缩略图,等等。有没有办法也能得到全尺寸的缩略图。我不想使用原始图像,我需要渲染的照片 我发现了一个代码,可以用来制作一个自定义大小的拇指,如果我可以用百分比代替像素,那就太完美了。如添加图像大小(“新大小”,90%) 谢谢。单程 首先获取图像大小 $data = getimagesize($image_path); $width = $data[0]; $height = $data[1]; 获得10%的宽度和高度 $thumbW

当你上传图片时,wordpress会制作150x150、全尺寸的缩略图,等等。有没有办法也能得到全尺寸的缩略图。我不想使用原始图像,我需要渲染的照片

我发现了一个代码,可以用来制作一个自定义大小的拇指,如果我可以用百分比代替像素,那就太完美了。如添加图像大小(“新大小”,90%)

谢谢。

单程

首先获取图像大小

$data = getimagesize($image_path);
$width = $data[0];
$height = $data[1];
获得10%的宽度和高度

$thumbWidth = $width * 10 / 100;
$thumbhHeight = $height * 10 / 100;
和使用

add_image_size( 'new-size', $thumbWidth, $thumbhHeight, true );

非常感谢。但是如何获得图像路径呢?你能帮我一个工作代码吗?我在这里发现了一些东西,但我不能让它工作
add_image_size( 'new-size', $thumbWidth, $thumbhHeight, true );