我正在使用WpeMatico插件,该插件使用以下方式在帖子中保存图像:
$attach_id = wp_insert_attachment( $attachment, $filename, $postid );
wp-includes/post.php
> wp_insert_attachment
函数,但不太清楚如何调整图像大小。我希望所有/任何图像的最大大小为1024
按比例调整大小。我也有调整大小的功能,只是不知道如何使用它。谢谢
我正在使用WpeMatico插件,该插件使用以下方式在帖子中保存图像:
$attach_id = wp_insert_attachment( $attachment, $filename, $postid );
wp-includes/post.php
> wp_insert_attachment
函数,但不太清楚如何调整图像大小。我希望所有/任何图像的最大大小为1024
按比例调整大小。我也有调整大小的功能,只是不知道如何使用它。谢谢
原始图像大小(即“完整”)从不修改。中间图像大小在多个位置进行控制:
默认图像大小(\'thumbnail\'
, \'medium\'
, \'large\'
): 核心设置,通过Dashboard -> Settings -> Mediafunctions.php 文件,通过add_image_size()
\'thumbnail\' ): 主题functions.php file, via
设置\\u post\\u thumbnail\\u size()`默认情况下\'large\'
图像大小限制为1024px. 因此,您只需在需要1024px图像的位置输出此图像大小。
如果需要创建自定义图像大小,只需为现有图像重新生成缩略图。
\'full\'
图像大小,然后您需要在上载过程中修改它,即通过挂接wp_handle_upload
, 并执行调整大小。有各种插件可以实现这一点。出现快速搜索:
我最近添加了三种新尺寸的post\\u缩略图的主题支持,我想调整之前上传的所有旧图像的大小。我自己写的剧本如下:function resizeImages() { require ( ABSPATH . \'wp-admin/includes/image.php\' ); global $wpdb; $images = $wpdb->get_results( \"SELECT ID FROM $wpdb->posts